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
19033366
Commit
19033366
authored
Feb 06, 2017
by
Steve Müller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix drivers' exec() method to not execute via prepared statements
parent
aec4faf2
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
40 additions
and
49 deletions
+40
-49
DB2Connection.php
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
+6
-3
SQLAnywhereConnection.php
...octrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
+4
-4
SQLSrvConnection.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
+6
-3
DataAccessTest.php
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
+3
-3
ExceptionTest.php
tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
+11
-18
SqliteSchemaManagerTest.php
.../Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
+3
-3
TemporaryTableTest.php
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
+3
-7
DBAL202Test.php
tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php
+1
-1
TypeConversionTest.php
tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php
+2
-4
WriteTest.php
tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
+1
-3
No files found.
lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php
View file @
19033366
...
...
@@ -113,10 +113,13 @@ class DB2Connection implements Connection, ServerInfoAwareConnection
*/
public
function
exec
(
$statement
)
{
$stmt
=
$this
->
prepare
(
$statement
);
$stmt
->
execute
();
$stmt
=
@
db2_exec
(
$this
->
_conn
,
$statement
);
if
(
false
===
$stmt
)
{
throw
new
DB2Exception
(
db2_stmt_errormsg
());
}
return
$stmt
->
rowCount
(
);
return
db2_num_rows
(
$stmt
);
}
/**
...
...
lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php
View file @
19033366
...
...
@@ -121,11 +121,11 @@ class SQLAnywhereConnection implements Connection, ServerInfoAwareConnection
*/
public
function
exec
(
$statement
)
{
$stmt
=
$this
->
prepare
(
$statement
);
$stmt
->
execute
();
if
(
false
===
sasql_real_query
(
$this
->
connection
,
$statement
))
{
throw
SQLAnywhereException
::
fromSQLAnywhereError
(
$this
->
connection
);
}
return
$stmt
->
rowCount
(
);
return
sasql_affected_rows
(
$this
->
connection
);
}
/**
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php
View file @
19033366
...
...
@@ -118,10 +118,13 @@ class SQLSrvConnection implements Connection, ServerInfoAwareConnection
*/
public
function
exec
(
$statement
)
{
$stmt
=
$this
->
prepare
(
$statement
);
$stmt
->
execute
();
$stmt
=
sqlsrv_query
(
$this
->
conn
,
$statement
);
if
(
false
===
$stmt
)
{
throw
SQLSrvException
::
fromSqlSrvErrors
();
}
return
$stmt
->
rowCount
(
);
return
sqlsrv_rows_affected
(
$stmt
);
}
/**
...
...
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
View file @
19033366
...
...
@@ -590,7 +590,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
*/
public
function
testBitComparisonExpressionSupport
()
{
$this
->
_conn
->
exec
uteQuery
(
'DELETE FROM fetch_table'
)
->
execute
(
);
$this
->
_conn
->
exec
(
'DELETE FROM fetch_table'
);
$platform
=
$this
->
_conn
->
getDatabasePlatform
();
$bitmap
=
array
();
...
...
@@ -771,7 +771,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
*/
public
function
testEmptyFetchColumnReturnsFalse
()
{
$this
->
_conn
->
exec
uteQuery
(
'DELETE FROM fetch_table'
)
->
execute
(
);
$this
->
_conn
->
exec
(
'DELETE FROM fetch_table'
);
$this
->
assertFalse
(
$this
->
_conn
->
fetchColumn
(
'SELECT test_int FROM fetch_table'
));
$this
->
assertFalse
(
$this
->
_conn
->
query
(
'SELECT test_int FROM fetch_table'
)
->
fetchColumn
());
}
...
...
@@ -846,7 +846,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
private
function
setupFixture
()
{
$this
->
_conn
->
exec
uteQuery
(
'DELETE FROM fetch_table'
)
->
execute
(
);
$this
->
_conn
->
exec
(
'DELETE FROM fetch_table'
);
$this
->
_conn
->
insert
(
'fetch_table'
,
array
(
'test_int'
=>
1
,
'test_string'
=>
'foo'
,
...
...
tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
View file @
19033366
...
...
@@ -22,9 +22,7 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table
->
addColumn
(
'id'
,
'integer'
,
array
());
$table
->
setPrimaryKey
(
array
(
'id'
));
foreach
(
$this
->
_conn
->
getDatabasePlatform
()
->
getCreateTableSQL
(
$table
)
as
$sql
)
{
$this
->
_conn
->
executeQuery
(
$sql
);
}
$this
->
_conn
->
getSchemaManager
()
->
createTable
(
$table
);
$this
->
_conn
->
insert
(
"duplicatekey_table"
,
array
(
'id'
=>
1
));
...
...
@@ -43,17 +41,14 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public
function
testTableExistsException
()
{
$schemaManager
=
$this
->
_conn
->
getSchemaManager
();
$table
=
new
\Doctrine\DBAL\Schema\Table
(
"alreadyexist_table"
);
$table
->
addColumn
(
'id'
,
'integer'
,
array
());
$table
->
setPrimaryKey
(
array
(
'id'
));
$this
->
setExpectedException
(
'\Doctrine\DBAL\Exception\TableExistsException'
);
foreach
(
$this
->
_conn
->
getDatabasePlatform
()
->
getCreateTableSQL
(
$table
)
as
$sql
)
{
$this
->
_conn
->
executeQuery
(
$sql
);
}
foreach
(
$this
->
_conn
->
getDatabasePlatform
()
->
getCreateTableSQL
(
$table
)
as
$sql
)
{
$this
->
_conn
->
executeQuery
(
$sql
);
}
$schemaManager
->
createTable
(
$table
);
$schemaManager
->
createTable
(
$table
);
}
public
function
testForeignKeyConstraintViolationExceptionOnInsert
()
...
...
@@ -204,7 +199,7 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table
->
setPrimaryKey
(
array
(
'id'
));
foreach
(
$schema
->
toSql
(
$this
->
_conn
->
getDatabasePlatform
())
as
$sql
)
{
$this
->
_conn
->
exec
uteQuery
(
$sql
);
$this
->
_conn
->
exec
(
$sql
);
}
$this
->
setExpectedException
(
'\Doctrine\DBAL\Exception\NotNullConstraintViolationException'
);
...
...
@@ -219,7 +214,7 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table
->
addColumn
(
'id'
,
'integer'
,
array
());
foreach
(
$schema
->
toSql
(
$this
->
_conn
->
getDatabasePlatform
())
as
$sql
)
{
$this
->
_conn
->
exec
uteQuery
(
$sql
);
$this
->
_conn
->
exec
(
$sql
);
}
$this
->
setExpectedException
(
'\Doctrine\DBAL\Exception\InvalidFieldNameException'
);
...
...
@@ -237,7 +232,7 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table2
->
addColumn
(
'id'
,
'integer'
);
foreach
(
$schema
->
toSql
(
$this
->
_conn
->
getDatabasePlatform
())
as
$sql
)
{
$this
->
_conn
->
exec
uteQuery
(
$sql
);
$this
->
_conn
->
exec
(
$sql
);
}
$sql
=
'SELECT id FROM ambiguous_list_table, ambiguous_list_table_2'
;
...
...
@@ -254,7 +249,7 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table
->
addUniqueIndex
(
array
(
'id'
));
foreach
(
$schema
->
toSql
(
$this
->
_conn
->
getDatabasePlatform
())
as
$sql
)
{
$this
->
_conn
->
exec
uteQuery
(
$sql
);
$this
->
_conn
->
exec
(
$sql
);
}
$this
->
_conn
->
insert
(
"unique_field_table"
,
array
(
'id'
=>
5
));
...
...
@@ -268,9 +263,7 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table
->
addColumn
(
'id'
,
'integer'
,
array
());
$table
->
setPrimaryKey
(
array
(
'id'
));
foreach
(
$this
->
_conn
->
getDatabasePlatform
()
->
getCreateTableSQL
(
$table
)
as
$sql
)
{
$this
->
_conn
->
executeQuery
(
$sql
);
}
$this
->
_conn
->
getSchemaManager
()
->
createTable
(
$table
);
$sql
=
'SELECT id FRO syntax_error_table'
;
$this
->
setExpectedException
(
'\Doctrine\DBAL\Exception\SyntaxErrorException'
);
...
...
@@ -308,7 +301,7 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
setExpectedException
(
$exceptionClass
);
foreach
(
$schema
->
toSql
(
$conn
->
getDatabasePlatform
())
as
$sql
)
{
$conn
->
exec
uteQuery
(
$sql
);
$conn
->
exec
(
$sql
);
}
}
...
...
@@ -350,7 +343,7 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
setExpectedException
(
'Doctrine\DBAL\Exception\ConnectionException'
);
foreach
(
$schema
->
toSql
(
$conn
->
getDatabasePlatform
())
as
$sql
)
{
$conn
->
exec
uteQuery
(
$sql
);
$conn
->
exec
(
$sql
);
}
}
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/SqliteSchemaManagerTest.php
View file @
19033366
...
...
@@ -73,7 +73,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
public
function
testListForeignKeysFromExistingDatabase
()
{
$this
->
_conn
->
exec
uteQuery
(
<<<EOS
$this
->
_conn
->
exec
(
<<<EOS
CREATE TABLE user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
page INTEGER CONSTRAINT FK_1 REFERENCES page (key) DEFERRABLE INITIALLY DEFERRED,
...
...
@@ -144,7 +144,7 @@ EOS
if
(
version_compare
(
$version
[
'versionString'
],
'3.7.16'
,
'<'
))
{
$this
->
markTestSkipped
(
'This version of sqlite doesn\'t return the order of the Primary Key.'
);
}
$this
->
_conn
->
exec
uteQuery
(
<<<EOS
$this
->
_conn
->
exec
(
<<<EOS
CREATE TABLE non_default_pk_order (
id INTEGER,
other_id INTEGER,
...
...
@@ -173,7 +173,7 @@ CREATE TABLE dbal_1779 (
)
SQL;
$this
->
_conn
->
exec
uteQuery
(
$sql
);
$this
->
_conn
->
exec
(
$sql
);
$columns
=
$this
->
_sm
->
listTableColumns
(
'dbal_1779'
);
...
...
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
View file @
19033366
...
...
@@ -50,9 +50,7 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table
->
addColumn
(
"id"
,
"integer"
);
$table
->
setPrimaryKey
(
array
(
'id'
));
foreach
(
$platform
->
getCreateTableSQL
(
$table
)
as
$sql
)
{
$this
->
_conn
->
executeQuery
(
$sql
);
}
$this
->
_conn
->
getSchemaManager
()
->
createTable
(
$table
);
$this
->
_conn
->
beginTransaction
();
$this
->
_conn
->
insert
(
"nontemporary"
,
array
(
"id"
=>
1
));
...
...
@@ -87,9 +85,7 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table
->
addColumn
(
"id"
,
"integer"
);
$table
->
setPrimaryKey
(
array
(
'id'
));
foreach
(
$platform
->
getCreateTableSQL
(
$table
)
as
$sql
)
{
$this
->
_conn
->
executeQuery
(
$sql
);
}
$this
->
_conn
->
getSchemaManager
()
->
createTable
(
$table
);
$this
->
_conn
->
beginTransaction
();
$this
->
_conn
->
insert
(
"nontemporary"
,
array
(
"id"
=>
1
));
...
...
@@ -108,4 +104,4 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase
$rows
=
$this
->
_conn
->
fetchAll
(
'SELECT * FROM nontemporary'
);
$this
->
assertEquals
(
array
(),
$rows
,
"In an event of an error this result has one row, because of an implicit commit."
);
}
}
\ No newline at end of file
}
tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL202Test.php
View file @
19033366
...
...
@@ -16,7 +16,7 @@ class DBAL202Test extends \Doctrine\Tests\DbalFunctionalTestCase
}
if
(
$this
->
_conn
->
getSchemaManager
()
->
tablesExist
(
'DBAL202'
))
{
$this
->
_conn
->
exec
uteQuery
(
'DELETE FROM DBAL202'
);
$this
->
_conn
->
exec
(
'DELETE FROM DBAL202'
);
}
else
{
$table
=
new
\Doctrine\DBAL\Schema\Table
(
'DBAL202'
);
$table
->
addColumn
(
'id'
,
'integer'
);
...
...
tests/Doctrine/Tests/DBAL/Functional/TypeConversionTest.php
View file @
19033366
...
...
@@ -34,9 +34,7 @@ class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table
->
setPrimaryKey
(
array
(
'id'
));
try
{
foreach
(
$this
->
_conn
->
getDatabasePlatform
()
->
getCreateTableSQL
(
$table
)
as
$sql
)
{
$this
->
_conn
->
executeQuery
(
$sql
);
}
$this
->
_conn
->
getSchemaManager
()
->
createTable
(
$table
);
}
catch
(
\Exception
$e
)
{
}
...
...
@@ -98,4 +96,4 @@ class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase
}
}
}
}
\ No newline at end of file
}
tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
View file @
19033366
...
...
@@ -18,9 +18,7 @@ class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase
$table
->
addColumn
(
'test_string'
,
'string'
,
array
(
'notnull'
=>
false
));
$table
->
setPrimaryKey
(
array
(
'id'
));
foreach
(
$this
->
_conn
->
getDatabasePlatform
()
->
getCreateTableSQL
(
$table
)
as
$sql
)
{
$this
->
_conn
->
executeQuery
(
$sql
);
}
$this
->
_conn
->
getSchemaManager
()
->
createTable
(
$table
);
}
catch
(
\Exception
$e
)
{
}
...
...
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