Example #1
0
 /**
  * Nests another query builder query in the current query.
  *
  * @param RedBean_SQLHelper
  *
  * @return RedBean_SQLHelper
  */
 public function nest(RedBean_SQLHelper $sqlHelper)
 {
     list($sql, $params) = $sqlHelper->getQuery();
     $this->sql .= $sql;
     $this->params += $params;
     return $this;
 }
 /**
  * Adds WHERE clause conditions to ownList retrieval.
  * For instance to get the pages that belong to a book you would
  * issue the following command: $book->ownPage
  * However, to order these pages by number use:
  *
  * $book->with(' ORDER BY `number` ASC ')->ownPage
  *
  * the additional SQL snippet will be merged into the final
  * query.
  *
  * @param string|RedBean_SQLHelper $sql      SQL to be added to retrieval query.
  * @param array                    $bindings array with parameters to bind to SQL snippet
  *
  * @return RedBean_OODBBean
  */
 public function with($sql, $bindings = array())
 {
     if ($sql instanceof RedBean_SQLHelper) {
         list($this->withSql, $this->withParams) = $sql->getQuery();
     } else {
         $this->withSql = $sql;
         $this->withParams = $bindings;
     }
     return $this;
 }