コード例 #1
0
ファイル: SelectTest.php プロジェクト: lytc/sloths
 public function testFoundRowsWithCache()
 {
     $cacheManager = $this->getMock('Sloths\\Cache\\CacheManager', ['get']);
     $cacheManager->expects($this->once())->method('get')->with(Select::CACHE_KEY_PREFIX . '.' . md5("SELECT COUNT(*) FROM users"))->willReturnCallback(function ($key, &$success) {
         $success = true;
         return 10;
     });
     $select = new Select();
     $select->setCacheManager($cacheManager)->table('users')->remember(10);
     $this->assertSame(10, $select->foundRows());
 }
コード例 #2
0
ファイル: Table.php プロジェクト: lytc/sloths
 /**
  * @param null $columns
  * @return Select
  */
 public function select($columns = null)
 {
     $select = new Select();
     $select->setConnection($this->getConnectionManager()->getReadConnection())->table($this->getName());
     if ($this->cacheManager) {
         $select->setCacheManager($this->cacheManager);
     }
     if ($columns) {
         $select->select($columns);
     }
     return $select;
 }