/** * Execute a query, and return the results as models. * * @param Query $query The query to execute * * @throws QueryExecutionException * * @return Collection A set containing results */ public function fetch(Query $query) { if ($query->compiled === null) { $query->compile(); } // Prepare the statement $stmt = $this->prepareQuery($query); // Execute the statement if ($stmt->execute()) { // Package the results into models return $this->packageResults($stmt, $query); } return $this->error($stmt); }
/** * Execute a query, and return the results as models. * * @method fetch * * @param Query $query The query to execute * * @throws QueryExecutionException * * @return Collection A set containing results */ public function fetch(Query $query) { if ($query->compiled === null) { $query->compile(); } // Prepare the statement $stmt = $this->prepareQuery($query); // Execute the statement $success = $stmt->execute(); // Get the result object $result = $stmt->get_result(); if ($success && $result) { // Package the results into models return $this->packageResults($result, $query); } return $this->error(); }
/** * Compile and execute a query, and return its results. * * @param Query $query The query to execute * * @return Collection */ public function fetch(Query $query) { if ($query->compiled === null) { $query->compile(); } return $this->driver->fetch($query); }
/** * Compile a nested query object, and inject its query string * into the current query. * * @method compileSubquery * * @param Query $query The nested query object * * @return string The compiled subquery string */ private function compileSubquery(Query $query) { $this->subqueries[$query->table->alias] = $query; $query->compile(); return '(' . $query->compiled . ')'; }