Commit 1ad04795 authored by Bas de Nooijer's avatar Bas de Nooijer

Added support for placeholders to delete query

parent 3a44e32b
...@@ -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);
......
...@@ -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'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment