/** * Execute a query and fetch all rows as associative array * * @param string $query * @param array $parameters Query parameters * @return array[] * @throws \Phramework\Exceptions\DatabaseException * @example * ```php * $records = Database::executeAndFetchAll( * 'SELECT "id", "first_name" * FROM "user"' * ); * ``` */ public static function executeAndFetchAll($query, $parameters = [], $castModel = null) { try { return static::$adapter->executeAndFetchAll($query, $parameters); } catch (\Exception $e) { throw new DatabaseException('Database Error', $e->getMessage()); } }
/** * Execute a query and fetch all rows as associative array * * @param string $query * @param array $parameters Query parameters * @param array $castModel [Optional] Default is null * @return array[] * @throws Phramework\Exceptions\DatabaseException */ public function executeAndFetchAll($query, $parameters = [], $castModel = null) { $startTimestamp = time(); $exception = null; try { $result = $this->internalAdapter->executeAndFetchAll($query, $parameters); } catch (\Exception $e) { $exception = $e; } finally { //log $this->log($query, $parameters, $startTimestamp, $exception); if ($exception) { throw $exception; } } return $result; }