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


PHP CActiveRecord::findAll方法代碼示例

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


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

示例1: fetchData

 /**
  * fetch data
  */
 protected function fetchData()
 {
     $criteria = $this->_criteria;
     $criteria->offset = $this->_offset;
     $criteria->limit = $this->batchSize;
     $this->_batch = $this->_model->findAll($criteria);
     $this->_offset += $this->batchSize;
 }
開發者ID:Liv1020,項目名稱:yii-batch-result,代碼行數:11,代碼來源:BatchResult.php

示例2: getValidParents

 public function getValidParents()
 {
     $result = array();
     $criteria = new CDbCriteria();
     if (!$this->_model->getIsNewRecord()) {
         $criteria->addNotInCondition($this->getPK(), $this->getDescendantsIds($this->_model));
     }
     foreach ($this->_model->findAll($criteria) as $model) {
         $result[$model->{$this->getPK()}] = $model->getCaption();
     }
     return $result;
 }
開發者ID:hit-shappens,項目名稱:testapp,代碼行數:12,代碼來源:ParentChildARBehavior.php

示例3: findAll

 public function findAll($condition = '', $params = array())
 {
     $stores = parent::findAll($condition, $params);
     // add default store
     $default = self::getDefaultStore();
     array_unshift($stores, $default);
     return $stores;
 }
開發者ID:damnpoet,項目名稱:yiicart,代碼行數:8,代碼來源:Store.php

示例4: rewind

 /**
  * {@inheritDoc}
  * @see Iterator::rewind()
  */
 public function rewind()
 {
     $this->_current_index = 0;
     $this->_criteria->offset = 0;
     $this->_max_count = (int) $this->_model->count($this->_criteria);
     $this->_current_records = $this->_model->findAll($this->_criteria);
     $this->_current_records_size = count($this->_current_records);
 }
開發者ID:anastaszor,項目名稱:yii1-recorditerator,代碼行數:12,代碼來源:CRecordIterator.php

示例5: rewind

 /**
  * {@inheritDoc}
  * @see Iterator::rewind()
  */
 public function rewind()
 {
     $this->_current_index = 0;
     $this->_current_offset = 0;
     $this->_max_count = $this->_model->count($this->_criteria);
     $newcriteria = clone $this->_criteria;
     $this->_current_records = $this->_model->findAll($newcriteria);
     $this->_current_records_size = count($this->_current_records);
 }
開發者ID:anastaszor,項目名稱:yii1-recorditerator,代碼行數:13,代碼來源:COrderedIterator.php

示例6: rewind

 /**
  * {@inheritDoc}
  * @see Iterator::rewind()
  */
 public function rewind()
 {
     $this->_current_index = 0;
     $this->_current_offset = 0;
     $timedCriteria = clone $this->_criteria;
     $timedCriteria->compare($this->_date_field, $this->_date_value);
     $this->_max_count = $this->_model->count($timedCriteria);
     $this->_current_records = $this->_model->findAll($timedCriteria);
     $this->_current_records_size = count($this->_current_records);
 }
開發者ID:anastaszor,項目名稱:yii1-recorditerator,代碼行數:14,代碼來源:CTimedOrderedIterator.php

示例7: listData

 /**
  * @param CActiveRecord $model
  * @param string $valueField defaults to primary key field
  * @param string $textField defaults to primary key field
  * @return array
  */
 public static function listData($model, $valueField = '', $textField = '')
 {
     $pk = $model->metaData->tableSchema->primaryKey;
     if ($valueField === '') {
         $valueField = $pk;
     }
     if ($textField === '') {
         $textField = $valueField;
     }
     return CHtml::listData($model->findAll(array('select' => $valueField == $textField ? $valueField : $valueField . ',' . $textField)), $valueField, $textField);
 }
開發者ID:DarkAiR,項目名稱:test,代碼行數:17,代碼來源:EHtml.php

示例8: GET_DATA_IN

 /**
  * @param CActiveRecord $model
  * @param string|array $inValues
  * @param string $column
  * @return CActiveRecord
  */
 public static function GET_DATA_IN($model, $column = 'id', $inValues)
 {
     $criteria = new CDbCriteria();
     if (is_string($inValues)) {
         $inValues = explode(',', $inValues);
     }
     $criteria->addInCondition($column, $inValues);
     return $model->findAll($criteria);
 }
開發者ID:edarkzero,項目名稱:PetAdoption,代碼行數:15,代碼來源:ModelBase.php

示例9: GET_RANDOM_CRITERIA_OFFSET

 /**
  * @param CActiveRecord $model
  * @param CDbCriteria $criteria
  * @param int $length
  * @return CDbCriteria
  */
 public static function GET_RANDOM_CRITERIA_OFFSET($model, $criteria, $length = NULL)
 {
     $criteriaTmp = $criteria;
     $criteriaTmp->select = 't.id';
     $randomMax = count($model->findAll($criteriaTmp));
     if ($randomMax > $length) {
         if ($length == NULL) {
             $random = rand(0, $randomMax - 1);
         } else {
             $random = rand(0, $randomMax - $length);
         }
         $criteria->offset = $random;
     }
     return $criteria;
 }
開發者ID:edarkzero,項目名稱:GineObs,代碼行數:21,代碼來源:ModelBase.php

示例10: findAllAttributes

 /**
  * Finds all active records satisfying the specified condition, selecting only the requested
  * attributes and, if specified, the primary keys.
  * See {@link CActiveRecord::find} for detailed explanation about $condition and $params.
  * #MethodTracker
  * This method is based on {@link CActiveRecord::findAll}, from version 1.1.7 (r3135). Changes:
  * <ul>
  * <li>Selects only the specified attributes.</li>
  * <li>Detects and selects the representing column.</li>
  * <li>Detects and selects the PK attribute.</li>
  * </ul>
  * @param string|array $attributes The names of the attributes to be selected.
  * Optional. If not specified, the {@link representingColumn} will be used.
  * @param boolean $withPk Specifies if the primary keys will be selected.
  * @param mixed $condition Query condition or criteria.
  * @param array $params Parameters to be bound to an SQL statement.
  * @return array List of active records satisfying the specified condition. An empty array is returned if none is found.
  * @uses representingColumn
  */
 public function findAllAttributes($attributes = null, $withPk = false, $condition = '', $params = array())
 {
     Yii::trace(get_class($this) . '.findAllAttributes()', 'giix.components.GxActiveRecord');
     $criteria = $this->getCommandBuilder()->createCriteria($condition, $params);
     if ($attributes === null) {
         $attributes = $this->representingColumn();
     }
     if ($withPk) {
         $pks = self::model(get_class($this))->getTableSchema()->primaryKey;
         if (!is_array($pks)) {
             $pks = array($pks);
         }
         if (!is_array($attributes)) {
             $attributes = array($attributes);
         }
         $attributes = array_merge($pks, $attributes);
     }
     $criteria->select = $attributes;
     return parent::findAll($criteria);
 }
開發者ID:Rudianasaja,項目名稱:cycommerce,代碼行數:39,代碼來源:GxActiveRecord.php

示例11: findAll

 /**
  *
  * @param string $condition
  * @param array $params
  * @return array 
  */
 public function findAll($condition = '', $params = array())
 {
     if (CStubActiveRecord::isUnittests()) {
         return CallFactory::call($this, 'findAll');
     }
     return parent::findAll($condition, $params);
 }
開發者ID:anton-itscript,項目名稱:WM-Web,代碼行數:13,代碼來源:CStubActiveRecord.php

示例12: findAll

 public function findAll($condition = '', $params = array())
 {
     return $this->prepareRecords(parent::findAll($this->prepareCondition($condition), $params));
 }
開發者ID:kuzmina-mariya,項目名稱:unizaro-spa,代碼行數:4,代碼來源:EavActiveRecord.php

示例13: countTotalPages

 /**
  * Don't use now.
  *
  * @param \CActiveRecord $model - model class name.
  * @param array $params - params list.
  * @param int $page - current page.
  * @param int $min - left border
  * @param int $max - right border
  * @return int page number
  */
 private function countTotalPages($model, $params, $page, $min = 0, $max = 0)
 {
     if (!empty($model->findAll(array('limit' => 1, 'offset' => $params['limit'] * ($page - 1))))) {
         if (empty($model->findAll(array('limit' => 1, 'offset' => $params['limit'] * $page)))) {
             return $page;
         }
         $min = $page;
         $page = $max == 0 ? ceil($page * 1.5) : ceil($page + ($max - $page) / 2);
     } else {
         $max = $page;
         $page = $min == 0 ? ceil($page / 2) : ceil(($page - $min) * 1.5);
     }
     return $this->countTotalPages($model, $params, $page, $min, $max);
 }
開發者ID:JimmDiGriz,項目名稱:HGApi,代碼行數:24,代碼來源:CoreApiController.php


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