示例#1
0
 /**
  * Execute the query as a DELETE statement.
  *
  * Optionally, an ID may be passed to the method do delete a specific row.
  *
  * @param  int   $id
  * @return int
  */
 public function delete($id = null)
 {
     if (!is_null($id)) {
         $this->where('id', '=', $id);
     }
     return $this->connection->query($this->grammar->delete($this), $this->bindings);
 }
示例#2
0
 /**
  * Execute the query as a DELETE statement.
  *
  * Optionally, an ID may be passed to the method do delete a specific row.
  *
  * @param  int   $id
  * @return int
  */
 public function delete($id = null)
 {
     // If an ID is given to the method, we'll set the where clause to
     // match on the value of the ID. This allows the developer to
     // quickly delete a row by its primary key value.
     if (!is_null($id)) {
         $this->where('id', '=', $id);
     }
     $sql = $this->grammar->delete($this);
     return $this->connection->query($sql, $this->bindings);
 }
示例#3
0
 /**
  * Execute the query as a SELECT statement.
  *
  * @param  array  $columns
  * @return array
  */
 public function get($columns = array('*'))
 {
     if (is_null($this->selects)) {
         $this->select($columns);
     }
     $sql = $this->grammar->select($this);
     $results = $this->connection->query($sql, $this->bindings);
     // If the query has an offset and we are using the SQL Server grammar,
     // we need to spin through the results and remove the "rownum" from
     // each of the objects since there is no "offset".
     if ($this->offset > 0 and $this->grammar instanceof SQLServer) {
         array_walk($results, function ($result) {
             unset($result->rownum);
         });
     }
     // Reset the SELECT clause so more queries can be performed using
     // the same instance. This is helpful for getting aggregates and
     // then getting actual results from the query.
     $this->selects = null;
     return $results;
 }