Replace $conn->query()->fetch*() with $conn->fetch*()

parent 5ceeed8c
...@@ -158,7 +158,7 @@ class BlobTest extends FunctionalTestCase ...@@ -158,7 +158,7 @@ class BlobTest extends FunctionalTestCase
private function assertBlobContains(string $text): void private function assertBlobContains(string $text): void
{ {
$rows = $this->connection->query('SELECT blobfield FROM blob_table')->fetchFirstColumn(); $rows = $this->connection->fetchFirstColumn('SELECT blobfield FROM blob_table');
self::assertCount(1, $rows); self::assertCount(1, $rows);
......
...@@ -601,7 +601,7 @@ class DataAccessTest extends FunctionalTestCase ...@@ -601,7 +601,7 @@ class DataAccessTest extends FunctionalTestCase
$this->connection->insert('fetch_table', ['test_int' => 10, 'test_string' => 'foo']); $this->connection->insert('fetch_table', ['test_int' => 10, 'test_string' => 'foo']);
$sql = 'SELECT test_int FROM fetch_table'; $sql = 'SELECT test_int FROM fetch_table';
$values = $this->connection->query($sql)->fetchFirstColumn(); $values = $this->connection->fetchFirstColumn($sql);
self::assertEquals([1, 10], $values); self::assertEquals([1, 10], $values);
} }
......
...@@ -40,8 +40,7 @@ class ConnectionTest extends FunctionalTestCase ...@@ -40,8 +40,7 @@ class ConnectionTest extends FunctionalTestCase
self::assertEquals( self::assertEquals(
$charset, $charset,
$connection->query('SHOW client_encoding') $connection->fetchOne('SHOW client_encoding')
->fetchOne()
); );
} }
......
...@@ -27,7 +27,7 @@ class DateExpressionTest extends FunctionalTestCase ...@@ -27,7 +27,7 @@ class DateExpressionTest extends FunctionalTestCase
$platform = $this->connection->getDatabasePlatform(); $platform = $this->connection->getDatabasePlatform();
$sql = sprintf('SELECT %s FROM date_expr_test', $platform->getDateDiffExpression('date1', 'date2')); $sql = sprintf('SELECT %s FROM date_expr_test', $platform->getDateDiffExpression('date1', 'date2'));
$diff = $this->connection->query($sql)->fetchOne(); $diff = $this->connection->fetchOne($sql);
self::assertEquals($expected, $diff); self::assertEquals($expected, $diff);
} }
......
...@@ -69,9 +69,9 @@ class DefaultExpressionTest extends FunctionalTestCase ...@@ -69,9 +69,9 @@ class DefaultExpressionTest extends FunctionalTestCase
) )
); );
[$actualValue, $defaultValue] = $this->connection->query( [$actualValue, $defaultValue] = $this->connection->fetchNumeric(
'SELECT default_value, actual_value FROM default_expr_test' 'SELECT default_value, actual_value FROM default_expr_test'
)->fetchNumeric(); );
self::assertEquals($actualValue, $defaultValue); self::assertEquals($actualValue, $defaultValue);
} }
......
...@@ -145,9 +145,8 @@ class PortabilityTest extends FunctionalTestCase ...@@ -145,9 +145,8 @@ class PortabilityTest extends FunctionalTestCase
public function testFetchAllNullColumn(): void public function testFetchAllNullColumn(): void
{ {
$result = $this->connection->query('SELECT Test_Null FROM portability_table'); $column = $this->connection->fetchFirstColumn('SELECT Test_Null FROM portability_table');
$column = $result->fetchFirstColumn();
self::assertSame([null, null], $column); self::assertSame([null, null], $column);
} }
} }
...@@ -1440,17 +1440,17 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase ...@@ -1440,17 +1440,17 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$this->connection->insert('test_pk_auto_increment', ['text' => '1']); $this->connection->insert('test_pk_auto_increment', ['text' => '1']);
$result = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = \'1\''); $lastUsedIdBeforeDelete = (int) $this->connection->fetchOne(
"SELECT id FROM test_pk_auto_increment WHERE text = '1'"
$lastUsedIdBeforeDelete = (int) $result->fetchOne(); );
$this->connection->query('DELETE FROM test_pk_auto_increment'); $this->connection->query('DELETE FROM test_pk_auto_increment');
$this->connection->insert('test_pk_auto_increment', ['text' => '2']); $this->connection->insert('test_pk_auto_increment', ['text' => '2']);
$result = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = \'2\''); $lastUsedIdAfterDelete = (int) $this->connection->fetchOne(
"SELECT id FROM test_pk_auto_increment WHERE text = '2'"
$lastUsedIdAfterDelete = (int) $result->fetchOne(); );
self::assertGreaterThan($lastUsedIdBeforeDelete, $lastUsedIdAfterDelete); self::assertGreaterThan($lastUsedIdBeforeDelete, $lastUsedIdAfterDelete);
} }
......
...@@ -238,9 +238,9 @@ SQL; ...@@ -238,9 +238,9 @@ SQL;
$this->connection->insert('test_pk_auto_increment', ['text' => '2']); $this->connection->insert('test_pk_auto_increment', ['text' => '2']);
$result = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = "2"'); $lastUsedIdAfterDelete = (int) $this->connection->fetchOne(
'SELECT id FROM test_pk_auto_increment WHERE text = "2"'
$lastUsedIdAfterDelete = (int) $result->fetchOne(); );
// with an empty table, non autoincrement rowid is always 1 // with an empty table, non autoincrement rowid is always 1
self::assertEquals(1, $lastUsedIdAfterDelete); self::assertEquals(1, $lastUsedIdAfterDelete);
......
...@@ -36,7 +36,7 @@ class DBAL202Test extends FunctionalTestCase ...@@ -36,7 +36,7 @@ class DBAL202Test extends FunctionalTestCase
$stmt->execute(); $stmt->execute();
$this->connection->rollBack(); $this->connection->rollBack();
self::assertEquals(0, $this->connection->query('SELECT COUNT(1) FROM DBAL202')->fetchOne()); self::assertEquals(0, $this->connection->fetchOne('SELECT COUNT(1) FROM DBAL202'));
} }
public function testStatementCommit(): void public function testStatementCommit(): void
...@@ -46,6 +46,6 @@ class DBAL202Test extends FunctionalTestCase ...@@ -46,6 +46,6 @@ class DBAL202Test extends FunctionalTestCase
$stmt->execute(); $stmt->execute();
$this->connection->commit(); $this->connection->commit();
self::assertEquals(1, $this->connection->query('SELECT COUNT(1) FROM DBAL202')->fetchOne()); self::assertEquals(1, $this->connection->fetchOne('SELECT COUNT(1) FROM DBAL202'));
} }
} }
...@@ -174,8 +174,9 @@ class WriteTest extends FunctionalTestCase ...@@ -174,8 +174,9 @@ class WriteTest extends FunctionalTestCase
return strtolower($sequence->getName()) === 'write_table_id_seq'; return strtolower($sequence->getName()) === 'write_table_id_seq';
})); }));
$result = $this->connection->query($this->connection->getDatabasePlatform()->getSequenceNextValSQL('write_table_id_seq')); $nextSequenceVal = $this->connection->fetchOne(
$nextSequenceVal = $result->fetchOne(); $this->connection->getDatabasePlatform()->getSequenceNextValSQL('write_table_id_seq')
);
$lastInsertId = $this->lastInsertId('write_table_id_seq'); $lastInsertId = $this->lastInsertId('write_table_id_seq');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment