/** * Retrieve query results. * * Retrieve the results of the last executed query. * * @since 1.0.0 * @access public * * @return mixed Query results. * * @throws Freyja\Exceptions\RuntimeException if no query was ever executed in * this Database instance. */ public function get() { if (!isset($this->last)) { throw new RuntimeException('A query must be executed before retrieving the results.'); } return $this->last->getResult(); }
/** * Execute query. * * Execute the specified query. * * @since 1.1.0 Added $object parameter. * @since 1.0.0 * @access public * * @param Freyja\Database\Query\Query $query Query to execute. * @param string|bool $object Optional. If set, fetches results as the specified * object type (string) or StdClass (true). Default false. * @return self * * @throws Freyja\Exceptions\RuntimeException if it's raised by * Freyja\Database\Driver::execute(). */ public function execute(Query $query, $object = false) { if (!$query->hasResult()) { try { $result = $this->driver->execute($query, $object); } catch (Exception $e) { throw $e; } $query->setResult($result); } $this->last = $query; return $this; }