예제 #1
0
 /**
  * Bind Execute a query and return the row count
  *
  * @param  string $query Query string
  * @param  array  $parameters Query parameters
  * @return integer Returns the number of rows affected or selected
  * @throws \Phramework\Exceptions\DatabaseException
  * @uses PDOStatement::bindValue https://secure.php.net/manual/en/pdostatement.bindvalue.php
  * @example
  * ```php
  * $status = Database::bindExecute(
  *     'UPDATE "user"
  *     SET "first_name" = ?
  *     WHERE "id" = ?
  *     LIMIT 1',
  *     [
  *         $first_name, //PDO::PARAM_STR by default
  *         ['value' => $id, 'params' => \PDO::PARAM_INT]
  *     ]
  * );
  * ```
  */
 public static function bindExecute($query, $parameters = [])
 {
     try {
         return static::$adapter->bindExecute($query, $parameters);
     } catch (\Exception $e) {
         throw new DatabaseException('Database Error', $e->getMessage());
     }
 }
예제 #2
0
 /**
  * Bind Execute a query and return the row count
  *
  * @param string $query Query string
  * @param array  $parameters Query parameters
  * @return integer
  * @throws Phramework\Exceptions\DatabaseException
  * @todo provide documentation
  */
 public function bindExecute($query, $parameters = [])
 {
     $startTimestamp = time();
     $exception = null;
     try {
         $result = $this->internalAdapter->bindExecute($query, $parameters);
     } catch (\Exception $e) {
         $exception = $e;
     } finally {
         //log
         $this->log($query, $parameters, $startTimestamp, $exception);
         if ($exception) {
             throw $exception;
         }
     }
     return $result;
 }