Skip to content

Commit

Permalink
Merge pull request #3790 from cakephp/query-docs
Browse files Browse the repository at this point in the history
Update docs to use return $this
  • Loading branch information
ADmad committed Jun 24, 2014
2 parents bc348de + a41d646 commit 8e5fa19
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 77 deletions.
62 changes: 31 additions & 31 deletions src/Database/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function __construct($connection) {
* When called with a null argument, it will return the current connection instance.
*
* @param \Cake\Database\Connection $connection instance
* @return Query|\Cake\Database\Connection
* @return $this|\Cake\Database\Connection
*/
public function connection($connection = null) {
if ($connection === null) {
Expand Down Expand Up @@ -209,7 +209,7 @@ public function sql(ValueBinder $generator = null) {
*
* @param callable $visitor a function or callable to be executed for each part
* @param array $parts the query clasuses to traverse
* @return Query
* @return $this
*/
public function traverse(callable $visitor, array $parts = []) {
$parts = $parts ?: array_keys($this->_parts);
Expand Down Expand Up @@ -242,7 +242,7 @@ public function traverse(callable $visitor, array $parts = []) {
*
* @param array|ExpressionInterface|string $fields fields to be added to the list
* @param bool $overwrite whether to reset fields with passed list or not
* @return Query
* @return $this
*/
public function select($fields = [], $overwrite = false) {
if (is_callable($fields)) {
Expand Down Expand Up @@ -287,7 +287,7 @@ public function select($fields = [], $overwrite = false) {
*
* @param array|ExpressionInterface $on fields to be filtered on
* @param bool $overwrite whether to reset fields with passed list or not
* @return \Cake\Database\Query
* @return $this
*/
public function distinct($on = [], $overwrite = false) {
if ($on === []) {
Expand Down Expand Up @@ -327,7 +327,7 @@ public function distinct($on = [], $overwrite = false) {
*
* @param array|ExpressionInterface|string $modifiers modifiers to be applied to the query
* @param bool $overwrite whether to reset order with field list or not
* @return \Cake\Database\Query
* @return $this
*/
public function modifier($modifiers, $overwrite = false) {
$this->_dirty();
Expand Down Expand Up @@ -363,7 +363,7 @@ public function modifier($modifiers, $overwrite = false) {
*
* @param array|ExpressionInterface|string $tables tables to be added to the list
* @param bool $overwrite whether to reset tables with passed list or not
* @return Query
* @return $this
*/
public function from($tables = [], $overwrite = false) {
if (empty($tables)) {
Expand Down Expand Up @@ -468,7 +468,7 @@ public function from($tables = [], $overwrite = false) {
* @param array $types associative array of type names used to bind values to query
* @param bool $overwrite whether to reset joins with passed list or not
* @see \Cake\Database\Type
* @return Query
* @return $this
*/
public function join($tables = null, $types = [], $overwrite = false) {
if ($tables === null) {
Expand Down Expand Up @@ -614,7 +614,7 @@ public function join($tables = null, $types = [], $overwrite = false) {
* @param bool $overwrite whether to reset conditions with passed list or not
* @see \Cake\Database\Type
* @see \Cake\Database\QueryExpression
* @return \Cake\Database\Query
* @return $this
*/
public function where($conditions = null, $types = [], $overwrite = false) {
if ($overwrite) {
Expand Down Expand Up @@ -678,7 +678,7 @@ public function where($conditions = null, $types = [], $overwrite = false) {
* @param array $types associative array of type names used to bind values to query
* @see \Cake\Database\Query::where()
* @see \Cake\Database\Type
* @return \Cake\Database\Query
* @return $this
*/
public function andWhere($conditions, $types = []) {
$this->_conjugate('where', $conditions, 'AND', $types);
Expand Down Expand Up @@ -739,7 +739,7 @@ public function andWhere($conditions, $types = []) {
* @param array $types associative array of type names used to bind values to query
* @see \Cake\Database\Query::where()
* @see \Cake\Database\Type
* @return \Cake\Database\Query
* @return $this
*/
public function orWhere($conditions, $types = []) {
$this->_conjugate('where', $conditions, 'OR', $types);
Expand Down Expand Up @@ -788,7 +788,7 @@ public function orWhere($conditions, $types = []) {
*
* @param array|\Cake\Database\ExpressionInterface|string $fields fields to be added to the list
* @param bool $overwrite whether to reset order with field list or not
* @return \Cake\Database\Query
* @return $this
*/
public function order($fields, $overwrite = false) {
if ($overwrite) {
Expand Down Expand Up @@ -826,7 +826,7 @@ public function order($fields, $overwrite = false) {
*
* @param array|ExpressionInterface|string $fields fields to be added to the list
* @param bool $overwrite whether to reset fields with passed list or not
* @return \Cake\Database\Query
* @return $this
*/
public function group($fields, $overwrite = false) {
if ($overwrite) {
Expand All @@ -852,7 +852,7 @@ public function group($fields, $overwrite = false) {
* @param array $types associative array of type names used to bind values to query
* @param bool $overwrite whether to reset conditions with passed list or not
* @see \Cake\Database\Query::where()
* @return \Cake\Database\Query
* @return $this
*/
public function having($conditions = null, $types = [], $overwrite = false) {
if ($overwrite) {
Expand All @@ -871,7 +871,7 @@ public function having($conditions = null, $types = [], $overwrite = false) {
* @param string|array|ExpressionInterface|callback $conditions The AND conditions for HAVING.
* @param array $types associative array of type names used to bind values to query
* @see \Cake\Database\Query::andWhere()
* @return \Cake\Database\Query
* @return $this
*/
public function andHaving($conditions, $types = []) {
$this->_conjugate('having', $conditions, 'AND', $types);
Expand All @@ -887,7 +887,7 @@ public function andHaving($conditions, $types = []) {
* @param string|array|ExpressionInterface|callback $conditions The OR conditions for HAVING.
* @param array $types associative array of type names used to bind values to query.
* @see \Cake\Database\Query::orWhere()
* @return \Cake\Database\Query
* @return $this
*/
public function orHaving($conditions, $types = []) {
$this->_conjugate('having', $conditions, 'OR', $types);
Expand All @@ -904,7 +904,7 @@ public function orHaving($conditions, $types = []) {
* Pages should start at 1.
*
* @param int $num The page number you want.
* @return \Cake\Database\Query
* @return $this
*/
public function page($num) {
$limit = $this->clause('limit');
Expand Down Expand Up @@ -934,7 +934,7 @@ public function page($num) {
* }}}
*
* @param int|ExpressionInterface $num number of records to be returned
* @return \Cake\Database\Query
* @return $this
*/
public function limit($num) {
$this->_dirty();
Expand All @@ -961,7 +961,7 @@ public function limit($num) {
* }}}
*
* @param int|ExpressionInterface $num number of records to be skipped
* @return Query
* @return $this
*/
public function offset($num) {
if ($num !== null && !is_object($num)) {
Expand Down Expand Up @@ -993,7 +993,7 @@ public function offset($num) {
*
* @param string|Query $query full SQL query to be used in UNION operator
* @param bool $overwrite whether to reset the list of queries to be operated or not
* @return Query
* @return $this
*/
public function union($query, $overwrite = false) {
if ($overwrite) {
Expand Down Expand Up @@ -1026,7 +1026,7 @@ public function union($query, $overwrite = false) {
*
* @param string|Query $query full SQL query to be used in UNION operator
* @param bool $overwrite whether to reset the list of queries to be operated or not
* @return Query
* @return $this
*/
public function unionAll($query, $overwrite = false) {
if ($overwrite) {
Expand All @@ -1048,7 +1048,7 @@ public function unionAll($query, $overwrite = false) {
*
* @param array $columns The columns to insert into.
* @param array $types A map between columns & their datatypes.
* @return Query
* @return $this
* @throws \RuntimeException When there are 0 columns.
*/
public function insert(array $columns, array $types = []) {
Expand All @@ -1070,7 +1070,7 @@ public function insert(array $columns, array $types = []) {
* Set the table name for insert queries.
*
* @param string $table The table name to insert into.
* @return Query
* @return $this
*/
public function into($table) {
$this->_dirty();
Expand All @@ -1087,7 +1087,7 @@ public function into($table) {
* instance to insert data from another SELECT statement.
*
* @param array|Query $data The data to insert.
* @return Query
* @return $this
* @throws \Cake\Database\Exception if you try to set values before declaring columns.
* Or if you try to set values on non-insert queries.
*/
Expand Down Expand Up @@ -1119,7 +1119,7 @@ public function values($data) {
* Can be combined with set() and where() methods to create update queries.
*
* @param string $table The table you want to update.
* @return Query
* @return $this
*/
public function update($table) {
$this->_dirty();
Expand All @@ -1137,7 +1137,7 @@ public function update($table) {
* array or QueryExpression. When $key is an array, this parameter will be
* used as $types instead.
* @param array $types The column types to treat data as.
* @return Query
* @return $this
*/
public function set($key, $value = null, $types = []) {
if (empty($this->_parts['set'])) {
Expand Down Expand Up @@ -1165,7 +1165,7 @@ public function set($key, $value = null, $types = []) {
* create delete queries with specific conditions.
*
* @param string $table The table to use when deleting. This
* @return Query
* @return $this
*/
public function delete($table = null) {
$this->_dirty();
Expand All @@ -1189,7 +1189,7 @@ public function delete($table = null) {
* }}}
*
* @param string|\Cake\Database\QueryExpression $expression The expression to be appended
* @return \Cake\Database\Query
* @return $this
*/
public function epilog($expression = null) {
$this->_dirty();
Expand Down Expand Up @@ -1314,7 +1314,7 @@ public function clause($name) {
*
* @param null|callable $callback The callback to invoke when results are fetched.
* @param bool $overwrite Whether or not this should append or replace all existing decorators.
* @return \Cake\Database\Query
* @return $this
*/
public function decorateResults($callback, $overwrite = false) {
if ($overwrite) {
Expand All @@ -1338,7 +1338,7 @@ public function decorateResults($callback, $overwrite = false) {
*
* @param callable $callback the function to be executed for each ExpressionInterface
* found inside this query.
* @return \Cake\Database\Query
* @return $this
*/
public function traverseExpressions(callable $callback) {
$visitor = function($expression) use (&$visitor, $callback) {
Expand Down Expand Up @@ -1373,7 +1373,7 @@ public function traverseExpressions(callable $callback) {
* @param mixed $value The value to be bound
* @param string|int $type the mapped type name, used for casting when sending
* to database
* @return \Cake\Database\Query
* @return $this
*/
public function bind($param, $value, $type = 'string') {
$this->valueBinder()->bind($param, $value, $type);
Expand All @@ -1390,7 +1390,7 @@ public function bind($param, $value, $type = 'string') {
*
* @param \Cake\Database\ValueBinder $binder new instance to be set. If no value is passed the
* default one will be returned
* @return \Cake\Database\Query|\Cake\Database\ValueBinder
* @return $this|\Cake\Database\ValueBinder
*/
public function valueBinder($binder = null) {
if ($binder === null) {
Expand Down

0 comments on commit 8e5fa19

Please sign in to comment.