duxet\Rethinkdb\Query::run PHP Method

run() public method

public run ( $query = null )
    public function run($query = null)
    {
        $start = microtime(true);
        $query = $query ?: $this->query;
        $connection = $this->connection->getConnection();
        $result = $query->run($connection);
        $query = strval($this->query);
        $time = $this->connection->getElapsedTime($start);
        $this->connection->logQuery($query, [], $time);
        return $this->nativeArray($result);
    }

Usage Example

Example #1
0
 /**
  * Execute the query as a fresh "select" statement.
  *
  * @param array $columns
  *
  * @return array|static[]
  */
 public function getFresh($columns = [])
 {
     $this->compileOrders();
     $this->compileWheres();
     if ($this->offset) {
         $this->query->skip($this->offset);
     }
     if ($this->limit) {
         $this->query->limit($this->limit);
     }
     if ($this->columns) {
         $columns = $this->columns;
     }
     if (!empty($columns) && $columns[0] != '*') {
         $this->query->pluck($columns);
     }
     $results = $this->query->run();
     if (is_object($results)) {
         $results = $results->toArray();
     }
     if (isset($results['$reql_type$']) && $results['$reql_type$'] === 'GROUPED_DATA') {
         return $results['data'];
     }
     return $results;
 }