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
파일: Query.php 프로젝트: brandonlamb/spot
 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
파일: Query.php 프로젝트: vlucas/spot
 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);
 }