Пример #1
0
 protected function getSqlQueries()
 {
     $withDatabase = $this->withDatabase();
     if (!$withDatabase) {
         return 0;
     }
     // Calculate and return the total SQL Queries.
     $connection = DB::connection();
     $queries = $connection->getQueryLog();
     return count($queries);
 }
Пример #2
0
 public function __construct($connection = null)
 {
     $config = Config::get('profiler');
     if ($config['useForensics'] != true) {
         return;
     }
     if ($connection instanceof Connection) {
         $this->connection = $connection;
     } else {
         if ($config['withDatabase'] == true) {
             $this->connection = DB::connection();
         }
     }
     // Setup the View path.
     $this->viewPath = realpath(__DIR__) . DS . 'Views' . DS . 'Profiler.php';
     // Setup the Start Time.
     $this->startTime = Request::server('REQUEST_TIME_FLOAT');
 }
Пример #3
0
 /**
  * Table builder constructor.
  * Database class initialization, don't create too many instances of table builder,
  * because it will create many database instances which will decrease server performance.
  * By default this class would create an `id` field INT(11) NOT null AUTO_INCREMENT PRIMARY KEY, unless
  * you set the second parameter as false.
  *
  * @param PDO|null $db - PDO instance - it can be a instance given by DB::getPdo()
  * @param boolean  $id - A flag to add or not to add an `id` field automatically
  */
 public function __construct(PDO $db = null, $id = true)
 {
     // If the database is not given, create a new database instance.
     // If the database is in the same namespace, we don't need to specify namespace
     $this->db = $db ?: DB::getPdo();
     if ($id === true) {
         $this->addField('id', 'INT(11)', false, self::AUTO_INCREMENT);
         $this->setPK('id');
     }
 }