當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DboSource::read方法代碼示例

本文整理匯總了PHP中DboSource::read方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::read方法的具體用法?PHP DboSource::read怎麽用?PHP DboSource::read使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DboSource的用法示例。


在下文中一共展示了DboSource::read方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testRealQueries

 /**
  * testRealQueries method
  *
  * @return void
  */
 public function testRealQueries()
 {
     $this->loadFixtures('Apple', 'Article', 'User', 'Comment', 'Tag', 'Sample', 'ArticlesTag');
     $Apple = ClassRegistry::init('Apple');
     $Article = ClassRegistry::init('Article');
     $result = $this->Dbo->rawQuery('SELECT color, name FROM ' . $this->Dbo->fullTableName('apples'));
     $this->assertTrue(!empty($result));
     $result = $this->Dbo->fetchRow($result);
     $expected = array($this->Dbo->fullTableName('apples', false, false) => array('color' => 'Red 1', 'name' => 'Red Apple 1'));
     $this->assertEquals($expected, $result);
     $result = $this->Dbo->fetchAll('SELECT name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id');
     $expected = array(array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Red Apple 1')), array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Bright Red Apple')), array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'green blue')), array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Test Name')), array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Blue Green')), array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'My new apple')), array($this->Dbo->fullTableName('apples', false, false) => array('name' => 'Some odd color')));
     $this->assertEquals($expected, $result);
     $result = $this->Dbo->field($this->Dbo->fullTableName('apples', false, false), 'SELECT color, name FROM ' . $this->Dbo->fullTableName('apples') . ' ORDER BY id');
     $expected = array('color' => 'Red 1', 'name' => 'Red Apple 1');
     $this->assertEquals($expected, $result);
     $Apple->unbindModel(array(), false);
     $result = $this->Dbo->read($Apple, array('fields' => array($Apple->escapeField('name')), 'conditions' => null, 'recursive' => -1));
     $expected = array(array('Apple' => array('name' => 'Red Apple 1')), array('Apple' => array('name' => 'Bright Red Apple')), array('Apple' => array('name' => 'green blue')), array('Apple' => array('name' => 'Test Name')), array('Apple' => array('name' => 'Blue Green')), array('Apple' => array('name' => 'My new apple')), array('Apple' => array('name' => 'Some odd color')));
     $this->assertEquals($expected, $result);
     $result = $this->Dbo->read($Article, array('fields' => array('id', 'user_id', 'title'), 'conditions' => null, 'recursive' => 1));
     $this->assertTrue(Set::matches('/Article[id=1]', $result));
     $this->assertTrue(Set::matches('/Comment[id=1]', $result));
     $this->assertTrue(Set::matches('/Comment[id=2]', $result));
     $this->assertFalse(Set::matches('/Comment[id=10]', $result));
 }
開發者ID:laiello,項目名稱:double-l-bookmanagement,代碼行數:31,代碼來源:MysqlTest.php

示例2: testDistinctWithLimit

 /**
  * testDistinctWithLimit method
  *
  * @return void
  */
 public function testDistinctWithLimit()
 {
     $this->db->read($this->model, array('fields' => array('DISTINCT SqlserverTestModel.city', 'SqlserverTestModel.country'), 'limit' => 5));
     $result = $this->db->getLastQuery();
     $this->assertRegExp('/^SELECT DISTINCT TOP 5/', $result);
 }
開發者ID:netun0,項目名稱:cakephp-social-harvester,代碼行數:11,代碼來源:SqlserverTest.php

示例3: read

 /**
  * Returns an array of all result rows for a given SQL query.
  * Returns false if no rows matched.
  *
  * @param string $sql SQL statement
  * @param boolean $cache Enables returning/storing cached query results
  * @return array Array of resultset rows, or false if no rows matched
  */
 function read(&$model, $queryData = array(), $recursive = null)
 {
     $results = parent::read($model, $queryData, $recursive);
     $this->__fieldMappings = array();
     return $results;
 }
開發者ID:xplico,項目名稱:xplico,代碼行數:14,代碼來源:dbo_sqlsrv.php

示例4: testDistinctWithLimit

 /**
  * testDistinctWithLimit method
  *
  * @access public
  * @return void
  */
 function testDistinctWithLimit()
 {
     $this->db->read($this->model, array('fields' => array('DISTINCT MssqlTestModel.city', 'MssqlTestModel.country'), 'limit' => 5));
     $result = $this->db->getLastQuery();
     $this->assertPattern('/^SELECT DISTINCT TOP 5/', $result);
 }
開發者ID:kevinmel2000,項目名稱:Study-Buddy---CakePHP-Quiz-System,代碼行數:12,代碼來源:dbo_mssql.test.php

示例5: read

 /**
  * Returns an array of all result rows for a given SQL query.
  * Returns false if no rows matched.
  *
  * @param Model $model The model to read from
  * @param array $queryData The query data
  * @param int $recursive How many layers to go.
  * @return array|false Array of resultset rows, or false if no rows matched
  */
 public function read(Model $model, $queryData = array(), $recursive = null)
 {
     $results = parent::read($model, $queryData, $recursive);
     // 2014.09.30 SFICHERA: Commented in order to properly support joined models...
     //$this->_fieldMappings = array();
     return $results;
 }
開發者ID:jgprolluxer,項目名稱:prosales,代碼行數:16,代碼來源:Sqlserver.php

示例6: read

 /**
  * Returns an array of all result rows for a given SQL query.
  * Returns false if no rows matched.
  *
  * @param Model $model     The model to read from
  * @param array $queryData The query data
  * @param int   $recursive How many layers to go.
  *
  * @return array|false Array of resultset rows, or false if no rows matched
  */
 public function read(Model $model, $queryData = array(), $recursive = NULL)
 {
     $results = parent::read($model, $queryData, $recursive);
     $this->_fieldMappings = array();
     return $results;
 }
開發者ID:mrbadao,項目名稱:api-official,代碼行數:16,代碼來源:Sqlserver.php


注:本文中的DboSource::read方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。