public function testGetQueryLog()
 {
     ORM::forTable('widget')->findMany();
     $expected = "SELECT * FROM `widget`";
     $this->assertEquals($expected, ORM::getLastQuery());
     $log = Orm::getQueryLog();
     $this->assertTrue(is_array($log));
     $this->assertNotEmpty($log);
     $this->assertContains($expected, $log);
 }
Example #2
0
 /**
  * Return some dummy data
  */
 public function fetch($fetch_style = PDO::FETCH_BOTH, $cursor_orientation = PDO::FETCH_ORI_NEXT, $cursor_offset = 0)
 {
     // Hack to get searched for values and if searching for id = 9999
     // return false, as if it doesn't exist.
     //
     $mostRecent = array_pop(Orm::getQueryLog());
     if (stripos($mostRecent, "`id` = '9999'") !== false) {
         return false;
     }
     if ($this->current_row == 5) {
         return false;
     } else {
         $this->current_row++;
         return array('name' => 'Fred', 'age' => 10, 'id' => '1');
     }
 }