本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例12: findAll
public function findAll($condition = '', $params = array())
{
return $this->prepareRecords(parent::findAll($this->prepareCondition($condition), $params));
}
示例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);
}