Replace $conn->exec() and $conn->executeUpdate() with $conn->executeStatement()

parent d47675e2
......@@ -1027,23 +1027,6 @@ class Connection
return new Result($result, $this);
}
/**
* Executes an SQL INSERT/UPDATE/DELETE query with the given parameters
* and returns the number of affected rows.
*
* @deprecated Use {@link executeStatement()} instead.
*
* @param string $query The SQL query.
* @param array<mixed> $params The query parameters.
* @param array<int|string|null> $types The parameter types.
*
* @throws DBALException
*/
public function executeUpdate(string $query, array $params = [], array $types = []): int
{
return $this->executeStatement($query, $params, $types);
}
/**
* Executes an SQL statement with the given parameters and returns the number of affected rows.
*
......@@ -1410,7 +1393,7 @@ class Connection
throw ConnectionException::savepointsNotSupported();
}
$this->executeUpdate($this->platform->createSavePoint($savepoint));
$this->executeStatement($this->platform->createSavePoint($savepoint));
}
/**
......@@ -1432,7 +1415,7 @@ class Connection
return;
}
$this->executeUpdate($this->platform->releaseSavePoint($savepoint));
$this->executeStatement($this->platform->releaseSavePoint($savepoint));
}
/**
......@@ -1450,7 +1433,7 @@ class Connection
throw ConnectionException::savepointsNotSupported();
}
$this->executeUpdate($this->platform->rollbackSavePoint($savepoint));
$this->executeStatement($this->platform->rollbackSavePoint($savepoint));
}
/**
......
......@@ -30,7 +30,7 @@ class SQLSessionInit implements EventSubscriber
*/
public function postConnect(ConnectionEventArgs $args)
{
$args->getConnection()->executeUpdate($this->sql);
$args->getConnection()->executeStatement($this->sql);
}
/**
......
......@@ -278,7 +278,7 @@ class SQLServerSchemaManager extends AbstractSchemaManager
foreach ($tableDiff->removedColumns as $col) {
$columnConstraintSql = $this->getColumnConstraintSQL($tableDiff->name, $col->getName());
foreach ($this->_conn->fetchAllAssociative($columnConstraintSql) as $constraint) {
$this->_conn->exec(
$this->_conn->executeStatement(
sprintf(
'ALTER TABLE %s DROP CONSTRAINT %s',
$tableDiff->name,
......
......@@ -28,7 +28,7 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
{
foreach ($sql as $s) {
try {
$this->conn->exec($s);
$this->conn->executeStatement($s);
} catch (Throwable $e) {
}
}
......@@ -44,7 +44,7 @@ abstract class AbstractSchemaSynchronizer implements SchemaSynchronizer
protected function processSql(array $sql)
{
foreach ($sql as $s) {
$this->conn->exec($s);
$this->conn->executeStatement($s);
}
}
}
......@@ -17,7 +17,7 @@ class SQLSessionInitTest extends TestCase
{
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects(self::once())
->method('executeUpdate')
->method('executeStatement')
->with(self::equalTo("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"));
$eventArgs = new ConnectionEventArgs($connectionMock);
......
......@@ -546,7 +546,7 @@ class DataAccessTest extends FunctionalTestCase
*/
public function testBitComparisonExpressionSupport(): void
{
$this->connection->exec('DELETE FROM fetch_table');
$this->connection->executeStatement('DELETE FROM fetch_table');
$platform = $this->connection->getDatabasePlatform();
$bitmap = [];
......@@ -612,7 +612,7 @@ class DataAccessTest extends FunctionalTestCase
public function testEmptyFetchOneReturnsFalse(): void
{
$this->connection->beginTransaction();
$this->connection->exec('DELETE FROM fetch_table');
$this->connection->executeStatement('DELETE FROM fetch_table');
self::assertFalse($this->connection->fetchOne('SELECT test_int FROM fetch_table'));
$this->connection->rollBack();
}
......
......@@ -86,7 +86,7 @@ class ExceptionTest extends FunctionalTestCase
public function testForeignKeyConstraintViolationExceptionOnInsert(): void
{
if ($this->connection->getDatabasePlatform()->getName() === 'sqlite') {
$this->connection->exec('PRAGMA foreign_keys=ON');
$this->connection->executeStatement('PRAGMA foreign_keys=ON');
}
$this->setUpForeignKeyConstraintViolationExceptionTest();
......@@ -231,7 +231,7 @@ class ExceptionTest extends FunctionalTestCase
$table->setPrimaryKey(['id']);
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$this->expectException(Exception\NotNullConstraintViolationException::class);
......@@ -246,7 +246,7 @@ class ExceptionTest extends FunctionalTestCase
$table->addColumn('id', 'integer', []);
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$this->expectException(Exception\InvalidFieldNameException::class);
......@@ -264,7 +264,7 @@ class ExceptionTest extends FunctionalTestCase
$table2->addColumn('id', 'integer');
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$sql = 'SELECT id FROM ambiguous_list_table, ambiguous_list_table_2';
......@@ -281,7 +281,7 @@ class ExceptionTest extends FunctionalTestCase
$table->addUniqueIndex(['id']);
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$this->connection->insert('unique_field_table', ['id' => 5]);
......@@ -345,7 +345,7 @@ EOT
try {
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
$conn->exec($sql);
$conn->executeStatement($sql);
}
} finally {
$this->cleanupReadOnlyFile($filename);
......@@ -390,7 +390,7 @@ EOT
$this->expectException(Exception\ConnectionException::class);
foreach ($schema->toSql($conn->getDatabasePlatform()) as $sql) {
$conn->exec($sql);
$conn->executeStatement($sql);
}
}
......
......@@ -35,8 +35,15 @@ class ModifyLimitQueryTest extends FunctionalTestCase
self::$tableCreated = true;
}
$this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table'));
$this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2'));
$platform = $this->connection->getDatabasePlatform();
$this->connection->executeStatement(
$platform->getTruncateTableSQL('modify_limit_table')
);
$this->connection->executeStatement(
$platform->getTruncateTableSQL('modify_limit_table2')
);
}
public function testModifyLimitQuerySimpleQuery(): void
......
......@@ -62,7 +62,7 @@ class DefaultExpressionTest extends FunctionalTestCase
$table->addColumn('default_value', $type, ['default' => $defaultSql]);
$this->connection->getSchemaManager()->dropAndCreateTable($table);
$this->connection->exec(
$this->connection->executeStatement(
sprintf(
'INSERT INTO default_expr_test (actual_value) VALUES (%s)',
$defaultSql
......
......@@ -48,7 +48,7 @@ final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends FunctionalTestCa
$diff = (new Comparator())->compare($schema, $newSchema);
foreach ($diff->toSql($this->getPlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$validationSchema = $schemaManager->createSchema();
......
......@@ -26,7 +26,7 @@ class ForeignKeyTest extends FunctionalTestCase
);
foreach ($schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
self::assertCount(
......
......@@ -28,7 +28,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
}
TestUtil::getPrivilegedConnection()
->exec('GRANT ALL PRIVILEGES TO ' . $GLOBALS['db_user']);
->executeStatement('GRANT ALL PRIVILEGES TO ' . $GLOBALS['db_user']);
self::$privilegesGranted = true;
}
......
......@@ -66,10 +66,10 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testSupportDomainTypeFallback(): void
{
$createDomainTypeSQL = 'CREATE DOMAIN MyMoney AS DECIMAL(18,2)';
$this->connection->exec($createDomainTypeSQL);
$this->connection->executeStatement($createDomainTypeSQL);
$createTableSQL = 'CREATE TABLE domain_type_test (id INT PRIMARY KEY, value MyMoney)';
$this->connection->exec($createTableSQL);
$this->connection->executeStatement($createTableSQL);
$table = $this->connection->getSchemaManager()->listTableDetails('domain_type_test');
self::assertInstanceOf(DecimalType::class, $table->getColumn('value')->getType());
......@@ -154,7 +154,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
*/
public function testTableWithSchema(): void
{
$this->connection->exec('CREATE SCHEMA nested');
$this->connection->executeStatement('CREATE SCHEMA nested');
$nestedRelatedTable = new Table('nested.schemarelated');
$column = $nestedRelatedTable->addColumn('id', 'integer');
......@@ -190,10 +190,10 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testReturnQuotedAssets(): void
{
$sql = 'create table dbal91_something ( id integer CONSTRAINT id_something PRIMARY KEY NOT NULL ,"table" integer );';
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
$sql = 'ALTER TABLE dbal91_something ADD CONSTRAINT something_input FOREIGN KEY( "table" ) REFERENCES dbal91_something ON UPDATE CASCADE;';
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
$table = $this->schemaManager->listTableDetails('dbal91_something');
......@@ -349,8 +349,8 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testListTableDetailsWhenCurrentSchemaNameQuoted(): void
{
$this->connection->exec('CREATE SCHEMA "001_test"');
$this->connection->exec('SET search_path TO "001_test"');
$this->connection->executeStatement('CREATE SCHEMA "001_test"');
$this->connection->executeStatement('SET search_path TO "001_test"');
try {
$this->testListQuotedTable();
......
......@@ -86,7 +86,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
//TODO: SchemaDiff does not drop removed namespaces?
try {
//sql server versions below 2016 do not support 'IF EXISTS' so we have to catch the exception here
$this->connection->exec('DROP SCHEMA testschema');
$this->connection->executeStatement('DROP SCHEMA testschema');
} catch (DBALException $e) {
return;
}
......@@ -643,7 +643,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$diff->newNamespaces[] = 'testschema';
foreach ($diff->toSql($this->schemaManager->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
//test if table is create in namespace
......@@ -1505,7 +1505,7 @@ abstract class SchemaManagerFunctionalTestCase extends FunctionalTestCase
$sqls = $diff->toSql($platform);
foreach ($sqls as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$schema = new Schema([
......
......@@ -77,7 +77,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testListForeignKeysFromExistingDatabase(): void
{
$this->connection->exec(<<<EOS
$this->connection->executeStatement(<<<EOS
CREATE TABLE user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
page INTEGER CONSTRAINT FK_1 REFERENCES page (key) DEFERRABLE INITIALLY DEFERRED,
......@@ -165,7 +165,7 @@ CREATE TABLE dbal_1779 (
)
SQL;
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
$columns = $this->schemaManager->listTableColumns('dbal_1779');
......
......@@ -31,7 +31,7 @@ class TableGeneratorTest extends FunctionalTestCase
$schema->visit($visitor);
foreach ($schema->toSql($platform) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
} catch (Throwable $e) {
}
......
......@@ -13,7 +13,9 @@ class TemporaryTableTest extends FunctionalTestCase
{
parent::setUp();
try {
$this->connection->exec($this->connection->getDatabasePlatform()->getDropTableSQL('nontemporary'));
$this->connection->executeStatement(
$this->connection->getDatabasePlatform()->getDropTableSQL('nontemporary')
);
} catch (Throwable $e) {
}
}
......@@ -23,7 +25,9 @@ class TemporaryTableTest extends FunctionalTestCase
if ($this->connection) {
try {
$tempTable = $this->connection->getDatabasePlatform()->getTemporaryTableName('my_temporary');
$this->connection->exec($this->connection->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable));
$this->connection->executeStatement(
$this->connection->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable)
);
} catch (Throwable $e) {
}
}
......@@ -56,7 +60,9 @@ class TemporaryTableTest extends FunctionalTestCase
$this->connection->beginTransaction();
$this->connection->insert('nontemporary', ['id' => 1]);
$this->connection->exec($platform->getDropTemporaryTableSQL($tempTable));
$this->connection->executeStatement(
$platform->getDropTemporaryTableSQL($tempTable)
);
$this->connection->insert('nontemporary', ['id' => 2]);
$this->connection->rollBack();
......@@ -90,13 +96,15 @@ class TemporaryTableTest extends FunctionalTestCase
$this->connection->beginTransaction();
$this->connection->insert('nontemporary', ['id' => 1]);
$this->connection->exec($createTempTableSQL);
$this->connection->executeStatement($createTempTableSQL);
$this->connection->insert('nontemporary', ['id' => 2]);
$this->connection->rollBack();
try {
$this->connection->exec($platform->getDropTemporaryTableSQL($tempTable));
$this->connection->executeStatement(
$platform->getDropTemporaryTableSQL($tempTable)
);
} catch (Throwable $e) {
}
......
......@@ -19,7 +19,7 @@ class DBAL202Test extends FunctionalTestCase
}
if ($this->connection->getSchemaManager()->tablesExist('DBAL202')) {
$this->connection->exec('DELETE FROM DBAL202');
$this->connection->executeStatement('DELETE FROM DBAL202');
} else {
$table = new Table('DBAL202');
$table->addColumn('id', 'integer');
......
......@@ -26,8 +26,8 @@ class DBAL630Test extends FunctionalTestCase
}
try {
$this->connection->exec('CREATE TABLE dbal630 (id SERIAL, bool_col BOOLEAN NOT NULL);');
$this->connection->exec('CREATE TABLE dbal630_allow_nulls (id SERIAL, bool_col BOOLEAN);');
$this->connection->executeStatement('CREATE TABLE dbal630 (id SERIAL, bool_col BOOLEAN NOT NULL);');
$this->connection->executeStatement('CREATE TABLE dbal630_allow_nulls (id SERIAL, bool_col BOOLEAN);');
} catch (DBALException $e) {
}
......
......@@ -23,7 +23,7 @@ class DBAL752Test extends FunctionalTestCase
public function testUnsignedIntegerDetection(): void
{
$this->connection->exec(<<<SQL
$this->connection->executeStatement(<<<SQL
CREATE TABLE dbal752_unsigneds (
small SMALLINT,
small_unsigned SMALLINT UNSIGNED,
......
......@@ -277,7 +277,7 @@ class WriteTest extends FunctionalTestCase
}
foreach ($platform->getCreateTableSQL($table) as $sql) {
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
}
$seqName = $platform->usesSequenceEmulatedIdentityColumns()
......@@ -286,11 +286,11 @@ class WriteTest extends FunctionalTestCase
$sql = $platform->getEmptyIdentityInsertSQL('test_empty_identity', 'id');
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
$firstId = $this->lastInsertId($seqName);
$this->connection->exec($sql);
$this->connection->executeStatement($sql);
$secondId = $this->lastInsertId($seqName);
......
......@@ -106,7 +106,7 @@ class TestUtil
$stmts = $schema->toDropSql($testConn->getDatabasePlatform());
foreach ($stmts as $stmt) {
$testConn->exec($stmt);
$testConn->executeStatement($stmt);
}
}
}
......
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