本文整理匯總了PHP中CRUD::limit方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRUD::limit方法的具體用法?PHP CRUD::limit怎麽用?PHP CRUD::limit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRUD
的用法示例。
在下文中一共展示了CRUD::limit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: detail
public static function detail($orm, $id, $fields, $writable = true, $relations = null, $relations_limit = 10)
{
// 'main' will refer to main object, and 'rel' to its relations
$main_crud = new CRUD($orm, $fields);
$main_crud->filter(array('id' => array('=', $id)));
$_SESSION['CRUDPage']['crud'][$main_crud->getHash()] = $main_crud;
$main = array('hash' => $main_crud->getHash(), 'data' => $main_crud->getSingleRowWithTitles(), 'widgeted_data' => $main_crud->getWidgets($main_crud->getSingleRawRow()), 'id' => $id, 'writable' => $writable);
// Relations
$rels = array();
if ($relations) {
$main_model = $main_crud->getOrmClone()->find_one();
$main_model_name = $main_crud->getModelName();
foreach ($relations as $relator_mtd => $settings) {
list($fields, $details_url, $add_new, $defaults, $limit) = array_merge($settings, array(null, null, null, null));
// set default values
if (is_null($add_new)) {
$add_new = true;
}
if (is_null($defaults)) {
$defaults = array();
}
$crud = new CRUD($main_model->{$relator_mtd}(), $fields);
$crud->limit($relations_limit);
// set defaults
$rel_details = CRUD::parseRelationDetails($relator_mtd . '.', $main_model_name);
$key_name = $rel_details['key1'];
$crud->setDefaults(array_merge($defaults, array($key_name => $id)));
$_SESSION['CRUDPage']['crud'][$crud->getHash()] = $crud;
$rels[$relator_mtd] = array('hash' => $crud->getHash(), 'titles' => $crud->getTitles(), 'widgets' => $crud->getWidgets(), 'limit' => $crud->getLimit(), 'page_count' => $crud->getPageCount(), 'rel_title' => ucwords(str_replace('_', ' ', $relator_mtd)), 'add_new' => $add_new, 'details_url' => $details_url);
}
}
return json_encode(array('page_type' => 'detail', 'main' => $main, 'rels' => $rels));
}