Skip to content

Commit

Permalink
Completing doc block for Query::set()
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo committed Jan 13, 2016
1 parent bbf407d commit fa18ea6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 24 additions & 1 deletion src/Database/Query.php
Expand Up @@ -1374,8 +1374,31 @@ public function update($table)
/**
* Set one or many fields to update.
*
* @param string|array|QueryExpression $key The column name or array of keys
* ### Examples
*
* Passing a string:
*
* ```
* $query->update('articles')->set('title', 'The Title');
* ```
*
* Passing an array:
*
* ```
* $query->update('articles')->set(['title' => 'The Title'], ['title' => 'string']);
* ```
*
* Passing a callable:
*
* ```
* $query->update('articles')->set(function ($exp) {
* return $exp->eq('title', 'The title', 'string');
* });
* ```
*
* @param string|array|callable|QueryExpression $key The column name or array of keys
* + values to set. This can also be a QueryExpression containing a SQL fragment.
* It can also be a callable, that is required to return an expression object.
* @param mixed $value The value to update $key to. Can be null if $key is an
* array or QueryExpression. When $key is an array, this parameter will be
* used as $types instead.
Expand Down
2 changes: 1 addition & 1 deletion tests/TestCase/Database/QueryTest.php
Expand Up @@ -2492,7 +2492,7 @@ public function testUpdateSetCallable()
$query = new Query($this->connection);
$date = new \DateTime;
$query->update('comments')
->set(function ($exp) use ($date ){
->set(function ($exp) use ($date) {
return $exp
->eq('comment', 'mark')
->eq('created', $date, 'date');
Expand Down

0 comments on commit fa18ea6

Please sign in to comment.