예제 #1
0
 /**
  * Bind Execute a query and fetch first row as associative array
  *
  * @param  string $query Query string
  * @param  array  $parameters Query parameters
  * @return array
  * @throws \Phramework\Exceptions\DatabaseException
  */
 public static function bindExecuteAndFetch($query, $parameters = [], $castModel = null)
 {
     try {
         return static::$adapter->bindExecuteAndFetch($query, $parameters);
     } catch (\Exception $e) {
         throw new DatabaseException('Database Error', $e->getMessage());
     }
 }
예제 #2
0
 /**
  * Bind Execute a query and fetch first row as associative array
  *
  * @param string $query Query string
  * @param array  $parameters Query parameters
  * @param array $castModel [Optional] Default is null, if set
  * then \Phramework\Models\Filter::castEntry will be applied to data
  * @return array
  * @throws Phramework\Exceptions\DatabaseException
  */
 public function bindExecuteAndFetch($query, $parameters = [], $castModel = null)
 {
     $startTimestamp = time();
     $exception = null;
     try {
         $result = $this->internalAdapter->bindExecuteAndFetch($query, $parameters, $castModel);
     } catch (\Exception $e) {
         $exception = $e;
     } finally {
         //log
         $this->log($query, $parameters, $startTimestamp, $exception);
         if ($exception) {
             throw $exception;
         }
     }
     return $result;
 }