Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
1ad04795
Commit
1ad04795
authored
Jan 20, 2013
by
Bas de Nooijer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for placeholders to delete query
parent
3a44e32b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
library/Solarium/QueryType/Update/Query/Query.php
library/Solarium/QueryType/Update/Query/Query.php
+6
-1
tests/Solarium/Tests/QueryType/Update/Query/QueryTest.php
tests/Solarium/Tests/QueryType/Update/Query/QueryTest.php
+16
-0
No files found.
library/Solarium/QueryType/Update/Query/Query.php
View file @
1ad04795
...
@@ -276,10 +276,15 @@ class Query extends BaseQuery
...
@@ -276,10 +276,15 @@ class Query extends BaseQuery
* create you own command instance and use the add method.
* create you own command instance and use the add method.
*
*
* @param string $query
* @param string $query
* @param array $bind Bind values for placeholders in the query string
* @return self Provides fluent interface
* @return self Provides fluent interface
*/
*/
public
function
addDeleteQuery
(
$query
)
public
function
addDeleteQuery
(
$query
,
$bind
=
null
)
{
{
if
(
!
is_null
(
$bind
))
{
$query
=
$this
->
getHelper
()
->
assemble
(
$query
,
$bind
);
}
$delete
=
new
DeleteCommand
;
$delete
=
new
DeleteCommand
;
$delete
->
addQuery
(
$query
);
$delete
->
addQuery
(
$query
);
...
...
tests/Solarium/Tests/QueryType/Update/Query/QueryTest.php
View file @
1ad04795
...
@@ -261,6 +261,22 @@ class QueryTest extends \PHPUnit_Framework_TestCase
...
@@ -261,6 +261,22 @@ class QueryTest extends \PHPUnit_Framework_TestCase
);
);
}
}
public
function
testAddDeleteQueryWithBind
()
{
$this
->
query
->
addDeleteQuery
(
'id:%1%'
,
array
(
678
));
$commands
=
$this
->
query
->
getCommands
();
$this
->
assertEquals
(
Query
::
COMMAND_DELETE
,
$commands
[
0
]
->
getType
()
);
$this
->
assertEquals
(
array
(
'id:678'
),
$commands
[
0
]
->
getQueries
()
);
}
public
function
testAddDeleteQueries
()
public
function
testAddDeleteQueries
()
{
{
$this
->
query
->
addDeleteQueries
(
array
(
'id:1'
,
'id:2'
));
$this
->
query
->
addDeleteQueries
(
array
(
'id:1'
,
'id:2'
));
...
...
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