public function execute($sql, $params=array())
    {
        if(!is_array($params))
            $params = array_slice(func_get_args(),1);

        $mysqli = $this->_mysqli();
        $debug = $this->_debug;
        $sql = count($params) ? $this->binder()->bind($sql, $params) : $sql;

        // delegate execution to the filter chain
        return $this->_filter->execute($sql, function($sql) use ($mysqli, $debug) {
            \Pheasant\Database\Mysqli\Connection::$counter++;

            if($debug) {
                $timer = microtime(true);
            }

            $r = $mysqli->query($sql, MYSQLI_STORE_RESULT);

            if($debug) {
                \Pheasant\Database\Mysqli\Connection::$timer += microtime(true)-$timer;
            }

            if ($debug) {
                printf("<pre>Pheasant executed <code>%s</code> on thread #%d in %.2fms, returned %d rows</pre>\n\n",
                    $sql, $mysqli->thread_id, (microtime(true)-$timer)*1000, is_object($r) ? $r->num_rows : 0);
            }

            if ($mysqli->error) {
                if ($mysqli->errno === 1213 || $mysqli->errno === 1479) {
                    throw new DeadlockException($mysqli->error, $mysqli->errno);
                } else {
                    throw new Exception($mysqli->error, $mysqli->errno);
                }
            }

            return new ResultSet($mysqli, $r === true ? false : $r);
        });
    }
public function execute($sql, $params=array())
    {
        if(!is_array($params))
            $params = array_slice(func_get_args(),1);

        $mysqli = $this->_mysqli();
        $debug = $this->_debug;
        $sql = count($params) ? $this->binder()->bind($sql, $params) : $sql;

        // delegate execution to the filter chain
        return $this->_filter->execute($sql, function($sql) use ($mysqli, $debug) {
            \Pheasant\Database\Mysqli\Connection::$counter++;

            if($debug) {
                $timer = microtime(true);
            }

            $r = $mysqli->query($sql, MYSQLI_STORE_RESULT);

            if($debug) {
                \Pheasant\Database\Mysqli\Connection::$timer += microtime(true)-$timer;
            }

            if ($debug) {
                printf("<pre>Pheasant executed <code>%s</code> on thread #%d in %.2fms, returned %d rows</pre>\n\n",
                    $sql, $mysqli->thread_id, (microtime(true)-$timer)*1000, is_object($r) ? $r->num_rows : 0);
            }

            if ($mysqli->error) {
                if ($mysqli->errno === 1213 || $mysqli->errno === 1479) {
                    throw new DeadlockException($mysqli->error, $mysqli->errno);
                } else {
                    throw new Exception($mysqli->error, $mysqli->errno);
                }
            }

            return new ResultSet($mysqli, $r === true ? false : $r);
        });
    }
public function execute ( $ sql , $ params = array ( ) ) { if ( ! is_array ( $ params ) ) $ params = array_slice ( func_get_args ( ) , 1 ) ; $ mysqli = $ this -> _mysqli ( ) ; $ debug = $ this -> _debug ; $ sql = count ( $ params ) ? $ this -> binder ( ) -> bind ( $ sql , $ params ) : $ sql ; // delegate execution to the filter chain return $ this -> _filter -> execute ( $ sql , function ( $ sql ) use ( $ mysqli , $ debug ) { \ Pheasant \ Database \ Mysqli \ Connection :: $ counter ++ ; if ( $ debug ) { $ timer = microtime ( true ) ; } $ r = $ mysqli -> query ( $ sql , MYSQLI_STORE_RESULT ) ; if ( $ debug ) { \ Pheasant \ Database \ Mysqli \ Connection :: $ timer += microtime ( true ) - $ timer ; } if ( $ debug ) { printf ( "<pre>Pheasant executed <code>%s</code> on thread #%d in %.2fms, returned %d rows</pre>\n\n" , $ sql , $ mysqli -> thread_id , ( microtime ( true ) - $ timer ) * 1000 , is_object ( $ r ) ? $ r -> num_rows : 0 ) ; } if ( $ mysqli -> error ) { if ( $ mysqli -> errno === 1213 || $ mysqli -> errno === 1479 ) { throw new DeadlockException ( $ mysqli -> error , $ mysqli -> errno ) ; } else { throw new Exception ( $ mysqli -> error , $ mysqli -> errno ) ; } } return new ResultSet ( $ mysqli , $ r === true ? false : $ r ) ; } ) ; }
Executes a statement
@return ResultSet
Executes a statement