Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
524a23b0
Unverified
Commit
524a23b0
authored
Jul 10, 2020
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate executeUpdate() in favor of executeStatement()
parent
cedf3a28
Changes
29
Show whitespace changes
Inline
Side-by-side
Showing
29 changed files
with
118 additions
and
78 deletions
+118
-78
UPGRADE.md
UPGRADE.md
+4
-0
data-retrieval-and-manipulation.rst
docs/en/reference/data-retrieval-and-manipulation.rst
+6
-6
security.rst
docs/en/reference/security.rst
+1
-1
sharding_azure_tutorial.rst
docs/en/reference/sharding_azure_tutorial.rst
+1
-1
insert_data.php
docs/examples/sharding/insert_data.php
+1
-1
Connection.php
lib/Doctrine/DBAL/Connection.php
+37
-10
PrimaryReadReplicaConnection.php
...octrine/DBAL/Connections/PrimaryReadReplicaConnection.php
+14
-2
MysqlSessionInit.php
lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php
+1
-1
OracleSessionInit.php
lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
+1
-1
TableGenerator.php
lib/Doctrine/DBAL/Id/TableGenerator.php
+1
-1
QueryBuilder.php
lib/Doctrine/DBAL/Query/QueryBuilder.php
+1
-4
AbstractSchemaManager.php
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
+1
-1
OracleSchemaManager.php
lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
+3
-3
RunSqlCommand.php
lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
+1
-1
LoggingTest.php
tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php
+2
-2
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+14
-14
MysqlSessionInitTest.php
tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php
+1
-1
OracleSessionInitTest.php
tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php
+2
-2
DataAccessTest.php
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
+4
-4
ConnectionTest.php
...rine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php
+1
-1
ExceptionTest.php
tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
+1
-1
MasterSlaveConnectionTest.php
...trine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php
+1
-1
PrimaryReadReplicaConnectionTest.php
...ests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php
+1
-1
MySqlSchemaManagerTest.php
...e/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
+1
-1
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+1
-1
TemporaryTableTest.php
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
+1
-1
DBAL630Test.php
tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
+2
-2
WriteTest.php
tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
+9
-9
RunSqlCommandTest.php
...s/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php
+4
-4
No files found.
UPGRADE.md
View file @
524a23b0
# Upgrade to 2.11
## Deprecations in the wrapper `Connection` class
1.
The
`executeUpdate()`
method has been deprecated in favor of
`executeStatement()`
.
## PDO-related classes outside of the PDO namespace are deprecated
The following outside of the PDO namespace have been deprecated in favor of their counterparts in the PDO namespace:
...
...
docs/en/reference/data-retrieval-and-manipulation.rst
View file @
524a23b0
...
...
@@ -142,7 +142,7 @@ use prepared statements:
SQL query, bind the given params with their binding types and execute the query.
This method returns the executed prepared statement for iteration and is useful
for SELECT statements.
- ``execute
Update
($sql, $params, $types)`` - Create a prepared statement for the passed
- ``execute
Statement
($sql, $params, $types)`` - Create a prepared statement for the passed
SQL query, bind the given params with their binding types and execute the query.
This method returns the number of affected rows by the executed query and is useful
for UPDATE, DELETE and INSERT statements.
...
...
@@ -170,7 +170,7 @@ of this query using the fetch API of a statement:
The fetch API of a prepared statement obviously works only for ``SELECT`` queries.
If you find it tedious to write all the prepared statement code you can alternatively use
the ``Doctrine\DBAL\Connection#executeQuery()`` and ``Doctrine\DBAL\Connection#execute
Update
()``
the ``Doctrine\DBAL\Connection#executeQuery()`` and ``Doctrine\DBAL\Connection#execute
Statement
()``
methods. See the API section below on details how to use them.
Additionally there are lots of convenience methods for data-retrieval and manipulation
...
...
@@ -208,7 +208,7 @@ which means this code works independent of the database you are using.
.. note::
Be aware this type conversion only works with ``Statement#bindValue()``,
``Connection#executeQuery()`` and ``Connection#execute
Update
()``. It
``Connection#executeQuery()`` and ``Connection#execute
Statement
()``. It
is not supported to pass a doctrine type name to ``Statement#bindParam()``,
because this would not work with binding by reference.
...
...
@@ -286,7 +286,7 @@ This is much more complicated and is ugly to write generically.
.. note::
The parameter list support only works with ``Doctrine\DBAL\Connection::executeQuery()``
and ``Doctrine\DBAL\Connection::execute
Update
()``, NOT with the binding methods of
and ``Doctrine\DBAL\Connection::execute
Statement
()``, NOT with the binding methods of
a prepared statement.
API
...
...
@@ -319,7 +319,7 @@ Prepare a given SQL statement and return the
)
*/
execute
Update
()
execute
Statement
()
~~~~~~~~~~~~~~~
Executes a prepared statement with the given SQL and parameters and
...
...
@@ -328,7 +328,7 @@ returns the affected rows count:
.. code-block:: php
<?php
$count = $conn->execute
Update
('UPDATE user SET username = ? WHERE id = ?', array('jwage', 1));
$count = $conn->execute
Statement
('UPDATE user SET username = ? WHERE id = ?', array('jwage', 1));
echo $count; // 1
The ``$types`` variable contains the PDO or Doctrine Type constants
...
...
docs/en/reference/security.rst
View file @
524a23b0
...
...
@@ -135,7 +135,7 @@ are using just the DBAL there are also helper methods which simplify the usage q
$sql = "SELECT * FROM users WHERE username = ?";
$stmt = $connection->executeQuery($sql, array($_GET['username']));
There is also ``execute
Update
`` which does not return a statement but the number of affected rows.
There is also ``execute
Statement
`` which does not return a statement but the number of affected rows.
Besides binding parameters you can also pass the type of the variable. This allows Doctrine or the underlying
vendor to not only escape but also cast the value to the correct type. See the docs on querying and DQL in the
...
...
docs/en/reference/sharding_azure_tutorial.rst
View file @
524a23b0
...
...
@@ -263,7 +263,7 @@ operation for us:
'LastName' => 'Brehm',
));
$conn->execute
Update
("DECLARE @orderId INT
$conn->execute
Statement
("DECLARE @orderId INT
DECLARE @customerId INT
...
...
docs/examples/sharding/insert_data.php
View file @
524a23b0
...
...
@@ -90,7 +90,7 @@ $conn->insert("Customers", array(
'LastName'
=>
'Brehm'
,
));
$conn
->
execute
Update
(
"
$conn
->
execute
Statement
(
"
DECLARE @orderId INT
DECLARE @customerId INT
...
...
lib/Doctrine/DBAL/Connection.php
View file @
524a23b0
...
...
@@ -749,7 +749,7 @@ class Connection implements DriverConnection
$this
->
addIdentifierCondition
(
$identifier
,
$columns
,
$values
,
$conditions
);
return
$this
->
execute
Update
(
return
$this
->
execute
Statement
(
'DELETE FROM '
.
$tableExpression
.
' WHERE '
.
implode
(
' AND '
,
$conditions
),
$values
,
is_string
(
key
(
$types
))
?
$this
->
extractTypeValues
(
$columns
,
$types
)
:
$types
...
...
@@ -777,7 +777,7 @@ class Connection implements DriverConnection
{
$this
->
transactionIsolationLevel
=
$level
;
return
$this
->
execute
Update
(
$this
->
getDatabasePlatform
()
->
getSetTransactionIsolationSQL
(
$level
));
return
$this
->
execute
Statement
(
$this
->
getDatabasePlatform
()
->
getSetTransactionIsolationSQL
(
$level
));
}
/**
...
...
@@ -827,7 +827,7 @@ class Connection implements DriverConnection
$sql
=
'UPDATE '
.
$tableExpression
.
' SET '
.
implode
(
', '
,
$set
)
.
' WHERE '
.
implode
(
' AND '
,
$conditions
);
return
$this
->
execute
Update
(
$sql
,
$values
,
$types
);
return
$this
->
execute
Statement
(
$sql
,
$values
,
$types
);
}
/**
...
...
@@ -846,7 +846,7 @@ class Connection implements DriverConnection
public
function
insert
(
$tableExpression
,
array
$data
,
array
$types
=
[])
{
if
(
empty
(
$data
))
{
return
$this
->
execute
Update
(
'INSERT INTO '
.
$tableExpression
.
' () VALUES ()'
);
return
$this
->
execute
Statement
(
'INSERT INTO '
.
$tableExpression
.
' () VALUES ()'
);
}
$columns
=
[];
...
...
@@ -859,7 +859,7 @@ class Connection implements DriverConnection
$set
[]
=
'?'
;
}
return
$this
->
execute
Update
(
return
$this
->
execute
Statement
(
'INSERT INTO '
.
$tableExpression
.
' ('
.
implode
(
', '
,
$columns
)
.
')'
.
' VALUES ('
.
implode
(
', '
,
$set
)
.
')'
,
$values
,
...
...
@@ -1285,6 +1285,8 @@ class Connection implements DriverConnection
*
* This method supports PDO binding types as well as DBAL mapping types.
*
* @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.
...
...
@@ -1294,19 +1296,44 @@ class Connection implements DriverConnection
* @throws DBALException
*/
public
function
executeUpdate
(
$query
,
array
$params
=
[],
array
$types
=
[])
{
return
$this
->
executeStatement
(
$query
,
$params
,
$types
);
}
/**
* Executes an SQL statement with the given parameters and returns the number of affected rows.
*
* Could be used for:
* - DML statements: INSERT, UPDATE, DELETE, etc.
* - DDL statements: CREATE, DROP, ALTER, etc.
* - DCL statements: GRANT, REVOKE, etc.
* - Session control statements: ALTER SESSION, SET, DECLARE, etc.
* - Other statements that don't yield a row set.
*
* This method supports PDO binding types as well as DBAL mapping types.
*
* @param string $sql The statement SQL
* @param array<mixed> $params The query parameters
* @param array<int|string|null> $types The parameter types
*
* @return int The number of affected rows.
*
* @throws DBALException
*/
public
function
executeStatement
(
$sql
,
array
$params
=
[],
array
$types
=
[])
{
$connection
=
$this
->
getWrappedConnection
();
$logger
=
$this
->
_config
->
getSQLLogger
();
if
(
$logger
)
{
$logger
->
startQuery
(
$
query
,
$params
,
$types
);
$logger
->
startQuery
(
$
sql
,
$params
,
$types
);
}
try
{
if
(
$params
)
{
[
$
query
,
$params
,
$types
]
=
SQLParserUtils
::
expandListParameters
(
$query
,
$params
,
$types
);
[
$
sql
,
$params
,
$types
]
=
SQLParserUtils
::
expandListParameters
(
$sql
,
$params
,
$types
);
$stmt
=
$connection
->
prepare
(
$
query
);
$stmt
=
$connection
->
prepare
(
$
sql
);
if
(
$types
)
{
$this
->
_bindTypedValues
(
$stmt
,
$params
,
$types
);
...
...
@@ -1317,10 +1344,10 @@ class Connection implements DriverConnection
$result
=
$stmt
->
rowCount
();
}
else
{
$result
=
$connection
->
exec
(
$
query
);
$result
=
$connection
->
exec
(
$
sql
);
}
}
catch
(
Throwable
$e
)
{
$this
->
handleExceptionDuringQuery
(
$e
,
$
query
,
$params
,
$types
);
$this
->
handleExceptionDuringQuery
(
$e
,
$
sql
,
$params
,
$types
);
}
if
(
$logger
)
{
...
...
lib/Doctrine/DBAL/Connections/PrimaryReadReplicaConnection.php
View file @
524a23b0
...
...
@@ -26,7 +26,7 @@ use function func_get_args;
*
* 1. Replica if primary was never picked before and ONLY if 'getWrappedConnection'
* or 'executeQuery' is used.
* 2. Primary picked when 'exec', 'executeUpdate', 'insert', 'delete', 'update', 'createSavepoint',
* 2. Primary picked when 'exec', 'executeUpdate', '
executeStatement', '
insert', 'delete', 'update', 'createSavepoint',
* 'releaseSavepoint', 'beginTransaction', 'rollback', 'commit', 'query' or
* 'prepare' is called.
* 3. If Primary was picked once during the lifetime of the connection it will always get picked afterwards.
...
...
@@ -41,7 +41,7 @@ use function func_get_args;
* Be aware that Connection#executeQuery is a method specifically for READ
* operations only.
*
* Use Connection#execute
Update
for any SQL statement that changes/updates
* Use Connection#execute
Statement
for any SQL statement that changes/updates
* state in the database (UPDATE, INSERT, DELETE or DDL statements).
*
* This connection is limited to replica operations using the
...
...
@@ -256,6 +256,8 @@ class PrimaryReadReplicaConnection extends Connection
/**
* {@inheritDoc}
*
* @deprecated Use {@link executeStatement()} instead.
*/
public
function
executeUpdate
(
$query
,
array
$params
=
[],
array
$types
=
[])
{
...
...
@@ -264,6 +266,16 @@ class PrimaryReadReplicaConnection extends Connection
return
parent
::
executeUpdate
(
$query
,
$params
,
$types
);
}
/**
* {@inheritDoc}
*/
public
function
executeStatement
(
$query
,
array
$params
=
[],
array
$types
=
[])
{
$this
->
ensureConnectedToPrimary
();
return
parent
::
executeStatement
(
$query
,
$params
,
$types
);
}
/**
* {@inheritDoc}
*/
...
...
lib/Doctrine/DBAL/Event/Listeners/MysqlSessionInit.php
View file @
524a23b0
...
...
@@ -45,7 +45,7 @@ class MysqlSessionInit implements EventSubscriber
public
function
postConnect
(
ConnectionEventArgs
$args
)
{
$collation
=
$this
->
collation
?
' COLLATE '
.
$this
->
collation
:
''
;
$args
->
getConnection
()
->
execute
Update
(
'SET NAMES '
.
$this
->
charset
.
$collation
);
$args
->
getConnection
()
->
execute
Statement
(
'SET NAMES '
.
$this
->
charset
.
$collation
);
}
/**
...
...
lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
View file @
524a23b0
...
...
@@ -61,7 +61,7 @@ class OracleSessionInit implements EventSubscriber
}
$sql
=
'ALTER SESSION SET '
.
implode
(
' '
,
$vars
);
$args
->
getConnection
()
->
execute
Update
(
$sql
);
$args
->
getConnection
()
->
execute
Statement
(
$sql
);
}
/**
...
...
lib/Doctrine/DBAL/Id/TableGenerator.php
View file @
524a23b0
...
...
@@ -131,7 +131,7 @@ class TableGenerator
$sql
=
'UPDATE '
.
$this
->
generatorTableName
.
' '
.
'SET sequence_value = sequence_value + sequence_increment_by '
.
'WHERE sequence_name = ? AND sequence_value = ?'
;
$rows
=
$this
->
conn
->
execute
Update
(
$sql
,
[
$sequenceName
,
$row
[
'sequence_value'
]]);
$rows
=
$this
->
conn
->
execute
Statement
(
$sql
,
[
$sequenceName
,
$row
[
'sequence_value'
]]);
if
(
$rows
!==
1
)
{
throw
new
DBALException
(
'Race-condition detected while updating sequence. Aborting generation'
);
...
...
lib/Doctrine/DBAL/Query/QueryBuilder.php
View file @
524a23b0
...
...
@@ -196,9 +196,6 @@ class QueryBuilder
/**
* Executes this query using the bound parameters and their types.
*
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
* for insert, update and delete statements.
*
* @return ResultStatement|int
*/
public
function
execute
()
...
...
@@ -207,7 +204,7 @@ class QueryBuilder
return
$this
->
connection
->
executeQuery
(
$this
->
getSQL
(),
$this
->
params
,
$this
->
paramTypes
);
}
return
$this
->
connection
->
execute
Update
(
$this
->
getSQL
(),
$this
->
params
,
$this
->
paramTypes
);
return
$this
->
connection
->
execute
Statement
(
$this
->
getSQL
(),
$this
->
params
,
$this
->
paramTypes
);
}
/**
...
...
lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
View file @
524a23b0
...
...
@@ -1033,7 +1033,7 @@ abstract class AbstractSchemaManager
protected
function
_execSql
(
$sql
)
{
foreach
((
array
)
$sql
as
$query
)
{
$this
->
_conn
->
execute
Update
(
$query
);
$this
->
_conn
->
execute
Statement
(
$query
);
}
}
...
...
lib/Doctrine/DBAL/Schema/OracleSchemaManager.php
View file @
524a23b0
...
...
@@ -307,10 +307,10 @@ class OracleSchemaManager extends AbstractSchemaManager
$password
=
$params
[
'password'
];
$query
=
'CREATE USER '
.
$username
.
' IDENTIFIED BY '
.
$password
;
$this
->
_conn
->
execute
Update
(
$query
);
$this
->
_conn
->
execute
Statement
(
$query
);
$query
=
'GRANT DBA TO '
.
$username
;
$this
->
_conn
->
execute
Update
(
$query
);
$this
->
_conn
->
execute
Statement
(
$query
);
}
/**
...
...
@@ -324,7 +324,7 @@ class OracleSchemaManager extends AbstractSchemaManager
$sql
=
$this
->
_platform
->
getDropAutoincrementSql
(
$table
);
foreach
(
$sql
as
$query
)
{
$this
->
_conn
->
execute
Update
(
$query
);
$this
->
_conn
->
execute
Statement
(
$query
);
}
return
true
;
...
...
lib/Doctrine/DBAL/Tools/Console/Command/RunSqlCommand.php
View file @
524a23b0
...
...
@@ -87,7 +87,7 @@ EOT
if
(
stripos
(
$sql
,
'select'
)
===
0
||
$input
->
getOption
(
'force-fetch'
))
{
$resultSet
=
$conn
->
fetchAllAssociative
(
$sql
);
}
else
{
$resultSet
=
$conn
->
execute
Update
(
$sql
);
$resultSet
=
$conn
->
execute
Statement
(
$sql
);
}
$output
->
write
(
Dumper
::
dump
(
$resultSet
,
(
int
)
$depth
));
...
...
tests/Doctrine/Tests/DBAL/Connection/LoggingTest.php
View file @
524a23b0
...
...
@@ -22,13 +22,13 @@ final class LoggingTest extends TestCase
->
executeQuery
(
'SELECT * FROM table'
);
}
public
function
testLogExecute
Update
()
:
void
public
function
testLogExecute
Statement
()
:
void
{
$this
->
createConnection
(
$this
->
createStub
(
DriverConnection
::
class
),
'UPDATE table SET foo = ?'
)
->
execute
Update
(
'UPDATE table SET foo = ?'
);
->
execute
Statement
(
'UPDATE table SET foo = ?'
);
}
public
function
testLogPrepareExecute
()
:
void
...
...
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
524a23b0
...
...
@@ -54,7 +54,7 @@ class ConnectionTest extends DbalTestCase
/**
* @return Connection|MockObject
*/
private
function
getExecute
Update
MockConnection
()
private
function
getExecute
Statement
MockConnection
()
{
$driverMock
=
$this
->
createMock
(
Driver
::
class
);
...
...
@@ -67,7 +67,7 @@ class ConnectionTest extends DbalTestCase
$platform
=
$this
->
getMockForAbstractClass
(
AbstractPlatform
::
class
);
return
$this
->
getMockBuilder
(
Connection
::
class
)
->
onlyMethods
([
'execute
Update
'
])
->
onlyMethods
([
'execute
Statement
'
])
->
setConstructorArgs
([[
'platform'
=>
$platform
],
$driverMock
])
->
getMock
();
}
...
...
@@ -203,7 +203,7 @@ class ConnectionTest extends DbalTestCase
[
'exec'
],
[
'query'
],
[
'executeQuery'
],
[
'execute
Update
'
],
[
'execute
Statement
'
],
[
'prepare'
],
];
}
...
...
@@ -372,10 +372,10 @@ class ConnectionTest extends DbalTestCase
public
function
testEmptyInsert
()
:
void
{
$conn
=
$this
->
getExecute
Update
MockConnection
();
$conn
=
$this
->
getExecute
Statement
MockConnection
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'execute
Update
'
)
->
method
(
'execute
Statement
'
)
->
with
(
'INSERT INTO footable () VALUES ()'
);
$conn
->
insert
(
'footable'
,
[]);
...
...
@@ -386,10 +386,10 @@ class ConnectionTest extends DbalTestCase
*/
public
function
testUpdateWithDifferentColumnsInDataAndIdentifiers
()
:
void
{
$conn
=
$this
->
getExecute
Update
MockConnection
();
$conn
=
$this
->
getExecute
Statement
MockConnection
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'execute
Update
'
)
->
method
(
'execute
Statement
'
)
->
with
(
'UPDATE TestTable SET text = ?, is_edited = ? WHERE id = ? AND name = ?'
,
[
...
...
@@ -430,10 +430,10 @@ class ConnectionTest extends DbalTestCase
*/
public
function
testUpdateWithSameColumnInDataAndIdentifiers
()
:
void
{
$conn
=
$this
->
getExecute
Update
MockConnection
();
$conn
=
$this
->
getExecute
Statement
MockConnection
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'execute
Update
'
)
->
method
(
'execute
Statement
'
)
->
with
(
'UPDATE TestTable SET text = ?, is_edited = ? WHERE id = ? AND is_edited = ?'
,
[
...
...
@@ -473,10 +473,10 @@ class ConnectionTest extends DbalTestCase
*/
public
function
testUpdateWithIsNull
()
:
void
{
$conn
=
$this
->
getExecute
Update
MockConnection
();
$conn
=
$this
->
getExecute
Statement
MockConnection
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'execute
Update
'
)
->
method
(
'execute
Statement
'
)
->
with
(
'UPDATE TestTable SET text = ?, is_edited = ? WHERE id IS NULL AND name = ?'
,
[
...
...
@@ -515,10 +515,10 @@ class ConnectionTest extends DbalTestCase
*/
public
function
testDeleteWithIsNull
()
:
void
{
$conn
=
$this
->
getExecute
Update
MockConnection
();
$conn
=
$this
->
getExecute
Statement
MockConnection
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'execute
Update
'
)
->
method
(
'execute
Statement
'
)
->
with
(
'DELETE FROM TestTable WHERE id IS NULL AND name = ?'
,
[
'foo'
],
...
...
@@ -725,7 +725,7 @@ class ConnectionTest extends DbalTestCase
[
'insert'
,
[
'tbl'
,
[
'data'
=>
'foo'
]]],
[
'update'
,
[
'tbl'
,
[
'data'
=>
'bar'
],
[
'id'
=>
12345
]]],
[
'prepare'
,
[
'select * from dual'
]],
[
'execute
Update
'
,
[
'insert into tbl (id) values (?)'
],
[
123
]],
[
'execute
Statement
'
,
[
'insert into tbl (id) values (?)'
],
[
123
]],
];
}
...
...
tests/Doctrine/Tests/DBAL/Events/MysqlSessionInitTest.php
View file @
524a23b0
...
...
@@ -14,7 +14,7 @@ class MysqlSessionInitTest extends DbalTestCase
{
$connectionMock
=
$this
->
createMock
(
Connection
::
class
);
$connectionMock
->
expects
(
$this
->
once
())
->
method
(
'execute
Update
'
)
->
method
(
'execute
Statement
'
)
->
with
(
$this
->
equalTo
(
'SET NAMES foo COLLATE bar'
));
$eventArgs
=
new
ConnectionEventArgs
(
$connectionMock
);
...
...
tests/Doctrine/Tests/DBAL/Events/OracleSessionInitTest.php
View file @
524a23b0
...
...
@@ -16,7 +16,7 @@ class OracleSessionInitTest extends DbalTestCase
{
$connectionMock
=
$this
->
createMock
(
Connection
::
class
);
$connectionMock
->
expects
(
$this
->
once
())
->
method
(
'execute
Update
'
)
->
method
(
'execute
Statement
'
)
->
with
(
$this
->
isType
(
'string'
));
$eventArgs
=
new
ConnectionEventArgs
(
$connectionMock
);
...
...
@@ -35,7 +35,7 @@ class OracleSessionInitTest extends DbalTestCase
->
disableOriginalConstructor
()
->
getMock
();
$connectionMock
->
expects
(
$this
->
once
())
->
method
(
'execute
Update
'
)
->
method
(
'execute
Statement
'
)
->
with
(
$this
->
stringContains
(
sprintf
(
'%s = %s'
,
$name
,
$value
)));
$eventArgs
=
new
ConnectionEventArgs
(
$connectionMock
);
...
...
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
View file @
524a23b0
...
...
@@ -437,12 +437,12 @@ class DataAccessTest extends DbalFunctionalTestCase
/**
* @group DDC-697
*/
public
function
testExecute
Update
BindDateTimeType
()
:
void
public
function
testExecute
Statement
BindDateTimeType
()
:
void
{
$datetime
=
new
DateTime
(
'2010-02-02 20:20:20'
);
$sql
=
'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)'
;
$affectedRows
=
$this
->
connection
->
execute
Update
(
$sql
,
[
$affectedRows
=
$this
->
connection
->
execute
Statement
(
$sql
,
[
1
=>
50
,
2
=>
'foo'
,
3
=>
$datetime
,
...
...
@@ -800,7 +800,7 @@ class DataAccessTest extends DbalFunctionalTestCase
public
function
testFetchAllStyleColumn
()
:
void
{
$sql
=
'DELETE FROM fetch_table'
;
$this
->
connection
->
execute
Update
(
$sql
);
$this
->
connection
->
execute
Statement
(
$sql
);
$this
->
connection
->
insert
(
'fetch_table'
,
[
'test_int'
=>
1
,
'test_string'
=>
'foo'
]);
$this
->
connection
->
insert
(
'fetch_table'
,
[
'test_int'
=>
10
,
'test_string'
=>
'foo'
]);
...
...
@@ -903,7 +903,7 @@ class DataAccessTest extends DbalFunctionalTestCase
*/
public
function
testFetchColumnNullValue
()
:
void
{
$this
->
connection
->
execute
Update
(
$this
->
connection
->
execute
Statement
(
'INSERT INTO fetch_table (test_int, test_string) VALUES (?, ?)'
,
[
2
,
'foo'
]
);
...
...
tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/ConnectionTest.php
View file @
524a23b0
...
...
@@ -40,7 +40,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$schemaManager
->
dropAndCreateTable
(
$table
);
$this
->
connection
->
execute
Update
(
'INSERT INTO DBAL2595 (foo) VALUES (1)'
);
$this
->
connection
->
execute
Statement
(
'INSERT INTO DBAL2595 (foo) VALUES (1)'
);
$schema
=
$this
->
connection
->
getDatabase
();
$sequence
=
$platform
->
getIdentitySequenceName
(
$schema
.
'.DBAL2595'
,
'id'
);
...
...
tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
View file @
524a23b0
...
...
@@ -201,7 +201,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this
->
expectException
(
Exception\ForeignKeyConstraintViolationException
::
class
);
try
{
$this
->
connection
->
execute
Update
(
$platform
->
getTruncateTableSQL
(
'constraint_error_table'
));
$this
->
connection
->
execute
Statement
(
$platform
->
getTruncateTableSQL
(
'constraint_error_table'
));
}
catch
(
Exception\ForeignKeyConstraintViolationException
$exception
)
{
$this
->
tearDownForeignKeyConstraintViolationExceptionTest
();
...
...
tests/Doctrine/Tests/DBAL/Functional/MasterSlaveConnectionTest.php
View file @
524a23b0
...
...
@@ -43,7 +43,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
}
catch
(
Throwable
$e
)
{
}
$this
->
connection
->
execute
Update
(
'DELETE FROM master_slave_table'
);
$this
->
connection
->
execute
Statement
(
'DELETE FROM master_slave_table'
);
$this
->
connection
->
insert
(
'master_slave_table'
,
[
'test_int'
=>
1
]);
}
...
...
tests/Doctrine/Tests/DBAL/Functional/PrimaryReadReplicaConnectionTest.php
View file @
524a23b0
...
...
@@ -43,7 +43,7 @@ class PrimaryReadReplicaConnectionTest extends DbalFunctionalTestCase
}
catch
(
Throwable
$e
)
{
}
$this
->
connection
->
execute
Update
(
'DELETE FROM primary_replica_table'
);
$this
->
connection
->
execute
Statement
(
'DELETE FROM primary_replica_table'
);
$this
->
connection
->
insert
(
'primary_replica_table'
,
[
'test_int'
=>
1
]);
}
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/MySqlSchemaManagerTest.php
View file @
524a23b0
...
...
@@ -458,7 +458,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this
->
schemaManager
->
dropAndCreateTable
(
$table
);
$this
->
connection
->
execute
Update
(
$this
->
connection
->
execute
Statement
(
'INSERT INTO test_column_defaults_are_valid () VALUES()'
);
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
524a23b0
...
...
@@ -224,7 +224,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$namespaces
=
array_map
(
'strtolower'
,
$namespaces
);
if
(
!
in_array
(
'test_create_schema'
,
$namespaces
))
{
$this
->
connection
->
execute
Update
(
$this
->
schemaManager
->
getDatabasePlatform
()
->
getCreateSchemaSQL
(
'test_create_schema'
));
$this
->
connection
->
execute
Statement
(
$this
->
schemaManager
->
getDatabasePlatform
()
->
getCreateSchemaSQL
(
'test_create_schema'
));
$namespaces
=
$this
->
schemaManager
->
listNamespaceNames
();
$namespaces
=
array_map
(
'strtolower'
,
$namespaces
);
...
...
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
View file @
524a23b0
...
...
@@ -49,7 +49,7 @@ class TemporaryTableTest extends DbalFunctionalTestCase
$createTempTableSQL
=
$platform
->
getCreateTemporaryTableSnippetSQL
()
.
' '
.
$tempTable
.
' ('
.
$platform
->
getColumnDeclarationListSQL
(
$columnDefinitions
)
.
')'
;
$this
->
connection
->
execute
Update
(
$createTempTableSQL
);
$this
->
connection
->
execute
Statement
(
$createTempTableSQL
);
$table
=
new
Table
(
'nontemporary'
);
$table
->
addColumn
(
'id'
,
'integer'
);
...
...
tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
View file @
524a23b0
...
...
@@ -48,7 +48,7 @@ class DBAL630Test extends DbalFunctionalTestCase
public
function
testBooleanConversionSqlLiteral
()
:
void
{
$this
->
connection
->
execute
Update
(
'INSERT INTO dbal630 (bool_col) VALUES(false)'
);
$this
->
connection
->
execute
Statement
(
'INSERT INTO dbal630 (bool_col) VALUES(false)'
);
$id
=
$this
->
connection
->
lastInsertId
(
'dbal630_id_seq'
);
self
::
assertNotEmpty
(
$id
);
...
...
@@ -59,7 +59,7 @@ class DBAL630Test extends DbalFunctionalTestCase
public
function
testBooleanConversionBoolParamRealPrepares
()
:
void
{
$this
->
connection
->
execute
Update
(
$this
->
connection
->
execute
Statement
(
'INSERT INTO dbal630 (bool_col) VALUES(?)'
,
[
'false'
],
[
ParameterType
::
BOOLEAN
]
...
...
tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
View file @
524a23b0
...
...
@@ -32,39 +32,39 @@ class WriteTest extends DbalFunctionalTestCase
}
catch
(
Throwable
$e
)
{
}
$this
->
connection
->
execute
Update
(
'DELETE FROM write_table'
);
$this
->
connection
->
execute
Statement
(
'DELETE FROM write_table'
);
}
/**
* @group DBAL-80
*/
public
function
testExecute
Update
FirstTypeIsNull
()
:
void
public
function
testExecute
Statement
FirstTypeIsNull
()
:
void
{
$sql
=
'INSERT INTO write_table (test_string, test_int) VALUES (?, ?)'
;
$this
->
connection
->
execute
Update
(
$sql
,
[
'text'
,
1111
],
[
null
,
ParameterType
::
INTEGER
]);
$this
->
connection
->
execute
Statement
(
$sql
,
[
'text'
,
1111
],
[
null
,
ParameterType
::
INTEGER
]);
$sql
=
'SELECT * FROM write_table WHERE test_string = ? AND test_int = ?'
;
self
::
assertTrue
((
bool
)
$this
->
connection
->
fetchColumn
(
$sql
,
[
'text'
,
1111
]));
}
public
function
testExecute
Update
()
:
void
public
function
testExecute
Statement
()
:
void
{
$sql
=
'INSERT INTO write_table (test_int) VALUES ( '
.
$this
->
connection
->
quote
(
1
)
.
')'
;
$affected
=
$this
->
connection
->
execute
Update
(
$sql
);
$affected
=
$this
->
connection
->
execute
Statement
(
$sql
);
self
::
assertEquals
(
1
,
$affected
,
'execute
Update
() should return the number of affected rows!'
);
self
::
assertEquals
(
1
,
$affected
,
'execute
Statement
() should return the number of affected rows!'
);
}
public
function
testExecute
Update
WithTypes
()
:
void
public
function
testExecute
Statement
WithTypes
()
:
void
{
$sql
=
'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)'
;
$affected
=
$this
->
connection
->
execute
Update
(
$affected
=
$this
->
connection
->
execute
Statement
(
$sql
,
[
1
,
'foo'
],
[
ParameterType
::
INTEGER
,
ParameterType
::
STRING
]
);
self
::
assertEquals
(
1
,
$affected
,
'execute
Update
() should return the number of affected rows!'
);
self
::
assertEquals
(
1
,
$affected
,
'execute
Statement
() should return the number of affected rows!'
);
}
public
function
testPrepareRowCountReturnsAffectedRows
()
:
void
...
...
tests/Doctrine/Tests/DBAL/Tools/Console/RunSqlCommandTest.php
View file @
524a23b0
...
...
@@ -79,7 +79,7 @@ class RunSqlCommandTest extends TestCase
public
function
testUpdateStatementsPrintsAffectedLines
()
:
void
{
$this
->
expectConnectionExecute
Update
();
$this
->
expectConnectionExecute
Statement
();
$this
->
commandTester
->
execute
([
'command'
=>
$this
->
command
->
getName
(),
...
...
@@ -90,11 +90,11 @@ class RunSqlCommandTest extends TestCase
self
::
assertDoesNotMatchRegularExpression
(
'@array.*1.*@'
,
$this
->
commandTester
->
getDisplay
());
}
private
function
expectConnectionExecute
Update
()
:
void
private
function
expectConnectionExecute
Statement
()
:
void
{
$this
->
connectionMock
->
expects
(
$this
->
once
())
->
method
(
'execute
Update
'
)
->
method
(
'execute
Statement
'
)
->
willReturn
(
42
);
$this
->
connectionMock
...
...
@@ -111,7 +111,7 @@ class RunSqlCommandTest extends TestCase
$this
->
connectionMock
->
expects
(
$this
->
never
())
->
method
(
'execute
Update
'
);
->
method
(
'execute
Statement
'
);
}
public
function
testStatementsWithFetchResultPrintsResult
()
:
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment