ORM::get_query_log PHP Method

get_query_log() public static method

Only works if the 'logging' config option is set to true. Otherwise, returned array will be empty.
public static get_query_log ( string $connection_name = self::DEFAULT_CONNECTION )
$connection_name string Which connection to use
    public static function get_query_log($connection_name = self::DEFAULT_CONNECTION)
    {
        if (isset(self::$_query_log[$connection_name])) {
            return self::$_query_log[$connection_name];
        }
        return array();
    }

Usage Example

Example #1
0
 function call()
 {
     $app = $this->app;
     $res = $app->response();
     try {
         $this->next->call();
         if (self::$disabled) {
             return;
         }
         if ($res->status() !== 200) {
             return;
         }
         $res['Content-Type'] = 'application/json';
         $result = self::prepForEncoding(self::$result);
         $res->status(200);
     } catch (Exception $e) {
         if ($e instanceof PDOException) {
             $log = $app->getLog();
             foreach (ORM::get_query_log() as $entry) {
                 $log->debug($entry);
             }
         }
         $res['Content-Type'] = 'application/json';
         $result = array('error' => $e->getMessage());
         $log = $app->getLog();
         $log->debug($e->getMessage() . "\n" . $e->getTraceAsString());
         if ($e instanceof AccessException) {
             $res->status($e->getCode());
         } else {
             $res->status(500);
         }
     }
     // encode
     $res->write(defined('JSON_PRETTY_PRINT') ? json_encode($result, JSON_PRETTY_PRINT & JSON_NUMERIC_CHECK) : json_encode($result, JSON_NUMERIC_CHECK));
 }
All Usage Examples Of ORM::get_query_log
ORM