yiiDebugDB::getInfo PHP Метод

getInfo() публичный статический Метод

public static getInfo ( $data, $config = null )
    public static function getInfo($data, $config = null)
    {
        parent::getInfo($data);
        $result = array();
        $result['panelTitle'] = 'Database Queries';
        $count = 0;
        $cached = 0;
        $items = array();
        foreach ($data as $row) {
            if (substr($row[2], 0, 9) == 'system.db') {
                $items[] = $row;
                if ($row[2] == 'system.db.CDbCommand') {
                    if (strpos($row[0], 'Querying SQL') !== false) {
                        $count++;
                    }
                    if (strpos($row[0], 'Query result found in cache') !== false) {
                        $cached++;
                    }
                }
            }
        }
        if (count($items) > 0) {
            $result['content'] = yiiDebugTrace::render($items);
        }
        $result['title'] = 'DB Query: ' . $count;
        if ($cached > 0) {
            $result['title'] .= " ({$cached} found in cache)";
        }
        return $result;
    }

Usage Example

Пример #1
0
 public function processLogs($logs)
 {
     $app = Yii::app();
     $config = array();
     $ip = $app->request->getUserHostAddress();
     $allowed = false;
     foreach ($this->allowedIPs as $pattern) {
         // if found any char other than [0-9] and dot, treat pattern as a regexp
         if (preg_match('/[^0-9:\\.]/', $pattern)) {
             if (preg_match('/' . $pattern . '/', $ip)) {
                 $allowed = true;
                 break;
             }
         } else {
             if ($pattern === $ip) {
                 $allowed = true;
                 break;
             }
         }
     }
     if (!$allowed) {
         return;
     }
     foreach (explode(',', $this->config) as $value) {
         $value = trim($value);
         $config[$value] = true;
     }
     //Checking for an AJAX Requests
     if (!$app instanceof CWebApplication || $app->getRequest()->getIsAjaxRequest()) {
         return;
     }
     //Checking for an DEBUG mode of running app
     if (isset($config['runInDebug']) && (!DEFINED('YII_DEBUG') || YII_DEBUG == false)) {
         return;
     }
     $items = array();
     $items[] = yiiDebugConfig::getInfo($logs, $config);
     $items[] = yiiDebugMem::getInfo($logs);
     $items[] = yiiDebugTime::getInfo($logs);
     $items[] = yiiDebugDB::getInfo($logs);
     $items[] = yiiDebugTrace::getInfo($logs);
     $panel = new yiiDebugPanel();
     $panel->render($items, $config);
 }
All Usage Examples Of yiiDebugDB::getInfo
yiiDebugDB