phprs\ezsql\impls\ExecImpl::exec PHP Method

exec() public static method

public static exec ( $context, $db, $exceOnError = true ) : Response
$context SqlConetxt
$db \PDO
$exceOnError boolean whether throw exceptions
return Response
    public static function exec($context, $db, $exceOnError = true)
    {
        if ($exceOnError) {
            $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
        }
        $db->setAttribute(\PDO::MYSQL_ATTR_FOUND_ROWS, true);
        $st = $db->prepare($context->sql);
        $success = $st->execute($context->params);
        return new Response($success, $db, $st);
    }

Usage Example

Example #1
0
 /**
  * Execute sql
  * @param \PDO $db
  * @param boolean $errExce whether throw exceptios
  * @return Response
  */
 public function exec($db, $errExce = true)
 {
     return ExecImpl::exec($this->context, $db, $errExce);
 }
ExecImpl