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
01760a4a
Commit
01760a4a
authored
Dec 18, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'DBAL-661' into 2.4
parents
4ce45f76
940ff55e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
8 deletions
+30
-8
Connection.php
lib/Doctrine/DBAL/Connection.php
+8
-7
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+22
-1
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
01760a4a
...
...
@@ -548,15 +548,16 @@ class Connection implements DriverConnection
{
$this
->
connect
();
if
(
!
is_int
(
key
(
$types
)
))
{
$types
=
$this
->
extractTypeValues
(
$data
,
$types
);
if
(
empty
(
$data
))
{
return
$this
->
executeUpdate
(
'INSERT INTO '
.
$tableName
.
' ()'
.
' VALUES ()'
);
}
$query
=
'INSERT INTO '
.
$tableName
.
' ('
.
implode
(
', '
,
array_keys
(
$data
))
.
')'
.
' VALUES ('
.
implode
(
', '
,
array_fill
(
0
,
count
(
$data
),
'?'
))
.
')'
;
return
$this
->
executeUpdate
(
$query
,
array_values
(
$data
),
$types
);
return
$this
->
executeUpdate
(
'INSERT INTO '
.
$tableName
.
' ('
.
implode
(
', '
,
array_keys
(
$data
))
.
')'
.
' VALUES ('
.
implode
(
', '
,
array_fill
(
0
,
count
(
$data
),
'?'
))
.
')'
,
array_values
(
$data
),
is_int
(
key
(
$types
))
?
$types
:
$this
->
extractTypeValues
(
$data
,
$types
)
);
}
/**
...
...
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
01760a4a
...
...
@@ -8,6 +8,7 @@ use Doctrine\DBAL\Connection;
use
Doctrine\Common\EventManager
;
use
Doctrine\DBAL\Configuration
;
use
Doctrine\DBAL\Events
;
use
Doctrine\Tests\Mocks\DriverConnectionMock
;
class
ConnectionTest
extends
\Doctrine\Tests\DbalTestCase
{
...
...
@@ -174,4 +175,24 @@ SQLSTATE[HY000]: General error: 1 near \"MUUHAAAAHAAAA\"");
$this
->
_conn
->
getConfiguration
()
->
setSQLLogger
(
$logger
);
$this
->
assertSame
(
$logger
,
$this
->
_conn
->
getConfiguration
()
->
getSQLLogger
());
}
public
function
testEmptyInsert
()
{
$driverMock
=
$this
->
getMock
(
'Doctrine\DBAL\Driver'
);
$driverMock
->
expects
(
$this
->
any
())
->
method
(
'connect'
)
->
will
(
$this
->
returnValue
(
new
DriverConnectionMock
()));
$conn
=
$this
->
getMockBuilder
(
'Doctrine\DBAL\Connection'
)
->
setMethods
(
array
(
'executeUpdate'
))
->
setConstructorArgs
(
array
(
array
(
'platform'
=>
new
Mocks\MockPlatform
()),
$driverMock
))
->
getMock
();
$conn
->
expects
(
$this
->
once
())
->
method
(
'executeUpdate'
)
->
with
(
'INSERT INTO footable () VALUES ()'
);
$conn
->
insert
(
'footable'
,
array
());
}
}
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