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

Get a count of how many queries have been run
public static queryCount ( ) : integer
Результат integer Total number of queries that have been run
Пример #1
0
 public function testQueryCountIsNotCachedForDifferentQueryResult()
 {
     $mapper = test_spot_mapper();
     $posts = $mapper->all('\\Spot\\Entity\\Post');
     $this->assertEquals(10, $posts->count());
     // Count # of queries
     $count1 = \Spot\Log::queryCount();
     // Change query so count will NOT be cached
     $this->assertEquals(3, $posts->where(array('status' => array(3, 4, 5)))->count());
     // Count again to ensure it is NOT cached since there are query changes
     $count2 = \Spot\Log::queryCount();
     $this->assertNotEquals($count1, $count2);
 }
Пример #2
0
 /**
  * Debug Spot queries by dumping query log
  */
 public function debugQueryLog()
 {
     if ($this->kernel->config('app.debug')) {
         // Executed queries
         echo "<hr />";
         echo "<h1>Executed Queries (" . \Spot\Log::queryCount() . ")</h1>";
         echo "<pre>";
         print_r(\Spot\Log::queries());
         echo "</pre>";
     }
 }
Пример #3
0
 public function testQueryHasOneWith()
 {
     $mapper = test_spot_mapper();
     $count1 = \Spot\Log::queryCount();
     $posts = $mapper->all('Entity_Post')->with(array('author'))->execute();
     $count2 = \Spot\Log::queryCount();
     // @todo: Theoretically, 'HasOne' calls could be added as JOIN
     $this->assertEquals($count1 + 2, $count2);
     foreach ($posts as $post) {
         $this->assertEquals($post->author_id, $post->author->id);
         $this->assertInstanceOf('\\Spot\\Relation\\HasOne', $post->author);
     }
     $count3 = \Spot\Log::queryCount();
     $this->assertEquals($count1 + 2, $count3);
 }