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
c5b4c9e6
Commit
c5b4c9e6
authored
Apr 01, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/pr/264' into DBAL-435
parents
89c3e54c
bf4e8439
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
15 deletions
+16
-15
SQLParserUtils.php
lib/Doctrine/DBAL/SQLParserUtils.php
+6
-4
SQLParserUtilsTest.php
tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
+10
-11
No files found.
lib/Doctrine/DBAL/SQLParserUtils.php
View file @
c5b4c9e6
...
@@ -130,11 +130,13 @@ class SQLParserUtils
...
@@ -130,11 +130,13 @@ class SQLParserUtils
$types
=
array_merge
(
$types
=
array_merge
(
array_slice
(
$types
,
0
,
$needle
),
array_slice
(
$types
,
0
,
$needle
),
array_fill
(
0
,
$count
,
$types
[
$needle
]
-
Connection
::
ARRAY_PARAM_OFFSET
),
// array needles are at PDO::PARAM_* + 100
$count
?
array_fill
(
0
,
$count
,
$types
[
$needle
]
-
Connection
::
ARRAY_PARAM_OFFSET
)
:
// array needles are at PDO::PARAM_* + 100
array
(),
array_slice
(
$types
,
$needle
+
1
)
array_slice
(
$types
,
$needle
+
1
)
);
);
$expandStr
=
implode
(
", "
,
array_fill
(
0
,
$count
,
"?"
))
;
$expandStr
=
$count
?
implode
(
", "
,
array_fill
(
0
,
$count
,
"?"
))
:
'NULL'
;
$query
=
substr
(
$query
,
0
,
$needlePos
)
.
$expandStr
.
substr
(
$query
,
$needlePos
+
1
);
$query
=
substr
(
$query
,
0
,
$needlePos
)
.
$expandStr
.
substr
(
$query
,
$needlePos
+
1
);
$paramOffset
+=
(
$count
-
1
);
// Grows larger by number of parameters minus the replaced needle.
$paramOffset
+=
(
$count
-
1
);
// Grows larger by number of parameters minus the replaced needle.
...
@@ -164,7 +166,7 @@ class SQLParserUtils
...
@@ -164,7 +166,7 @@ class SQLParserUtils
}
}
$count
=
count
(
$value
);
$count
=
count
(
$value
);
$expandStr
=
$count
>
0
?
implode
(
', '
,
array_fill
(
0
,
$count
,
'?'
))
:
'
?
'
;
$expandStr
=
$count
>
0
?
implode
(
', '
,
array_fill
(
0
,
$count
,
'?'
))
:
'
NULL
'
;
foreach
(
$value
as
$val
)
{
foreach
(
$value
as
$val
)
{
$paramsOrd
[]
=
$val
;
$paramsOrd
[]
=
$val
;
...
@@ -197,4 +199,4 @@ class SQLParserUtils
...
@@ -197,4 +199,4 @@ class SQLParserUtils
return
$fragments
[
1
];
return
$fragments
[
1
];
}
}
}
}
\ No newline at end of file
tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php
View file @
c5b4c9e6
...
@@ -108,21 +108,21 @@ SQLDATA
...
@@ -108,21 +108,21 @@ SQLDATA
array
(
1
,
2
,
3
,
4
,
5
),
array
(
1
,
2
,
3
,
4
,
5
),
array
(
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
)
array
(
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_INT
)
),
),
//
Positional
: Empty "integer" array DDC-1978
//
Positional
: Empty "integer" array DDC-1978
array
(
array
(
"SELECT * FROM Foo WHERE foo IN (?)"
,
"SELECT * FROM Foo WHERE foo IN (?)"
,
array
(
'foo'
=>
array
()),
array
(
array
()),
array
(
'foo'
=>
Connection
::
PARAM_INT_ARRAY
),
array
(
Connection
::
PARAM_INT_ARRAY
),
'SELECT * FROM Foo WHERE foo IN (
?
)'
,
'SELECT * FROM Foo WHERE foo IN (
NULL
)'
,
array
(),
array
(),
array
()
array
()
),
),
//
Positional
: Empty "str" array DDC-1978
//
Positional
: Empty "str" array DDC-1978
array
(
array
(
"SELECT * FROM Foo WHERE foo IN (?)"
,
"SELECT * FROM Foo WHERE foo IN (?)"
,
array
(
'foo'
=>
array
()),
array
(
array
()),
array
(
'foo'
=>
Connection
::
PARAM_STR_ARRAY
),
array
(
Connection
::
PARAM_STR_ARRAY
),
'SELECT * FROM Foo WHERE foo IN (
?
)'
,
'SELECT * FROM Foo WHERE foo IN (
NULL
)'
,
array
(),
array
(),
array
()
array
()
),
),
...
@@ -145,7 +145,6 @@ SQLDATA
...
@@ -145,7 +145,6 @@ SQLDATA
array
(
1
,
'Some String'
),
array
(
1
,
'Some String'
),
array
(
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_STR
)
array
(
\PDO
::
PARAM_INT
,
\PDO
::
PARAM_STR
)
),
),
// Named parameters : Very simple with one needle
// Named parameters : Very simple with one needle
array
(
array
(
"SELECT * FROM Foo WHERE foo IN (:foo)"
,
"SELECT * FROM Foo WHERE foo IN (:foo)"
,
...
@@ -224,7 +223,7 @@ SQLDATA
...
@@ -224,7 +223,7 @@ SQLDATA
"SELECT * FROM Foo WHERE foo IN (:foo)"
,
"SELECT * FROM Foo WHERE foo IN (:foo)"
,
array
(
'foo'
=>
array
()),
array
(
'foo'
=>
array
()),
array
(
'foo'
=>
Connection
::
PARAM_INT_ARRAY
),
array
(
'foo'
=>
Connection
::
PARAM_INT_ARRAY
),
'SELECT * FROM Foo WHERE foo IN (
?
)'
,
'SELECT * FROM Foo WHERE foo IN (
NULL
)'
,
array
(),
array
(),
array
()
array
()
),
),
...
@@ -233,7 +232,7 @@ SQLDATA
...
@@ -233,7 +232,7 @@ SQLDATA
"SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)"
,
"SELECT * FROM Foo WHERE foo IN (:foo) OR bar IN (:bar)"
,
array
(
'foo'
=>
array
(),
'bar'
=>
array
()),
array
(
'foo'
=>
array
(),
'bar'
=>
array
()),
array
(
'foo'
=>
Connection
::
PARAM_STR_ARRAY
,
'bar'
=>
Connection
::
PARAM_STR_ARRAY
),
array
(
'foo'
=>
Connection
::
PARAM_STR_ARRAY
,
'bar'
=>
Connection
::
PARAM_STR_ARRAY
),
'SELECT * FROM Foo WHERE foo IN (
?) OR bar IN (?
)'
,
'SELECT * FROM Foo WHERE foo IN (
NULL) OR bar IN (NULL
)'
,
array
(),
array
(),
array
()
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