public function find($conditions = null, $fields = array(), $order = null, $recursive = null) { if ($this->throwException) { throw new Exception('Model tried to query database.'); } return parent::find($conditions, $fields, $order, $recursive); }
function find($command, $options = array()) { if ($command == 'last') { $options = am(array('order' => 'id DESC'), $options); return parent::find('first', $options); } else { return parent::find($command, $options); } }
/** * find method * * @param mixed $type * @param array $options * @return void */ public function find($conditions = null, $fields = array(), $order = null, $recursive = null) { if ($conditions === 'popular') { $conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1'); $options = Hash::merge($fields, compact('conditions')); return parent::find('all', $options); } return parent::find($conditions, $fields); }
/** * ensure that getQueryLogs works and writes to the cache so the history panel will * work. * * @return void */ public function testGetQueryLogs() { $model = new CakeTestModel(array('table' => 'posts', 'alias' => 'Post')); $model->find('all'); $model->find('first'); $result = $this->Toolbar->getQueryLogs($model->useDbConfig, array('cache' => false)); $this->assertTrue(is_array($result)); $this->assertTrue(count($result) >= 2, 'Should be more than 2 queries in the log %s'); $this->assertTrue(isset($result['queries'][0]['actions'])); $model->find('first'); Cache::delete('debug_kit_toolbar_test_case', 'default'); $result = $this->Toolbar->getQueryLogs($model->useDbConfig, array('cache' => true)); $cached = $this->Toolbar->readCache('sql_log'); $this->assertTrue(isset($cached[$model->useDbConfig])); $this->assertEquals($cached[$model->useDbConfig]['queries'][0], $result['queries'][0]); }
/** * find method * * @param mixed $type * @param array $options * @access public * @return void */ function find($type, $options = array()) { if ($type == 'popular') { $conditions = array($this->name . '.' . $this->primaryKey . ' > ' => '1'); $options = Set::merge($options, compact('conditions')); return parent::find('all', $options); } return parent::find($type, $options); }
/** * test saving and retrieval of blobs * * @return void */ public function testBlobSaving() { $this->loadFixtures('BinaryTest'); $this->Dbo->cacheSources = false; $data = file_get_contents(CAKE . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'img' . DS . 'cake.power.gif'); $model = new CakeTestModel(array('name' => 'BinaryTest', 'ds' => 'test')); $model->save(compact('data')); $result = $model->find('first'); $this->assertEquals($data, $result['BinaryTest']['data']); }
/** * test saving and retrieval of blobs * * @return void */ public function testBlobSaving() { $this->loadFixtures('BinaryTest'); $this->Dbo->cacheSources = false; $data = "GIF87ab\n\t\tÒ4A¿¿¿ˇˇˇ,b\n\t\t¢îè©ÀÌ#¥⁄ã≥fi:¯Ü‚Héá¶jV∂ÓúÎL≥çÀóËıÎ…>ï≈ vFE%ÒâLFI<†µw˝±≈£7˘ç^H“≤«\f>Éâ*∑ÇnÖA•Ù|flêèj£:=ÿ6óUàµ5'∂®àA¬ñ∆ˆGE(gt’≈àÚyÁó«7\t‚VìöÇ√˙Ç™\n\t\tk”:;kÀAõ{*¡€Î˚˚[;;"; $model = new CakeTestModel(array('name' => 'BinaryTest', 'ds' => 'test')); $model->save(compact('data')); $result = $model->find('first'); $this->assertEqual($result['BinaryTest']['data'], $data); }