本文整理汇总了PHP中AppModel::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP AppModel::findAll方法的具体用法?PHP AppModel::findAll怎么用?PHP AppModel::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AppModel
的用法示例。
在下文中一共展示了AppModel::findAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findAll
public function findAll($params = array()) {
$polls = parent::findAll($params);
if(!$polls) return false;
foreach ($polls as $key => $value) {
$s = $this->connection->find("SELECT * FROM polls_responses WHERE polls_id = ".$polls[$key]['id']." ");
$polls[$key]['responses'] = $s;
}
return $polls;
}
示例2: recover
/**
* Recover a corrupted tree
*
* The mode parameter is used to specify the source of info that is valid/correct. The opposite source of data
* will be populated based upon that source of info. E.g. if the MPTT fields are corrupt or empty, with the $mode
* 'parent' the values of the parent_id field will be used to populate the left and right fields.
*
* @since 1.2
* @TODO Could be written to be faster, *maybe*. Ideally using a subquery and putting all the logic burden on the DB.
* @param AppModel $model
* @param string $mode parent or tree
* @return boolean True on success, false on failure
* @access public
*/
function recover(&$model, $mode = 'parent')
{
extract($this->settings[$model->name]);
$model->recursive = -1;
if ($mode == 'parent') {
$count = 1;
foreach ($model->findAll($scope, array($model->primaryKey)) as $Array) {
$model->{$model->primaryKey} = $Array[$model->name][$model->primaryKey];
$lft = $count++;
$rght = $count++;
$model->save(array($left => $lft, $right => $rght));
}
foreach ($model->findAll($scope, array($model->primaryKey, $parent)) as $Array) {
$model->create();
$model->id = $Array[$model->name][$model->primaryKey];
$this->_set_parent($model, $Array[$model->name][$parent], true);
}
} else {
foreach ($model->findAll($scope, array($model->primaryKey, $parent)) as $Array) {
$path = $this->get_path($model, $Array[$model->name][$model->primaryKey]);
if ($path == null || count($path) < 2) {
$parent_id = null;
} else {
$parent_id = $path[count($path) - 2][$model->name][$model->primaryKey];
}
// Sidestep beforeSave
$model->updateAll(array($parent => $parent_id), array($model->primaryKey => $Array[$model->name][$model->primaryKey]));
}
}
}