本文整理汇总了PHP中Package::find_all方法的典型用法代码示例。如果您正苦于以下问题:PHP Package::find_all方法的具体用法?PHP Package::find_all怎么用?PHP Package::find_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Package
的用法示例。
在下文中一共展示了Package::find_all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$this->set_default_side_bar();
$this->title = 'All Packages';
Nimble::set_title($this->title);
$page = isset($_GET['page']) ? $_GET['page'] : NULL;
switch ($this->format) {
case 'xml':
$this->packages = Package::find_all();
$this->header('Content-Type: text/xml', 200);
echo $this->packages->to_xml();
$this->layout = false;
$this->has_rendered = true;
break;
case 'json':
$this->packages = Package::find_all();
$this->header('Content-type: application/json', 200);
echo $this->packages->to_json();
$this->layout = false;
$this->has_rendered = true;
break;
case 'atom':
$this->layout = false;
$this->has_rendered = true;
break;
case 'rss':
$this->layout = false;
$this->has_rendered = true;
break;
default:
$this->full = true;
$this->packages = Package::paginate(array('select' => '`packages`.*, AVG(`package_ratings`.`rating`) as rating', 'order' => 'rating DESC', 'per_page' => 20, 'page' => $page, 'joins' => 'LEFT JOIN `package_ratings` on `package_ratings`.`package_id` = `packages`.`id`', 'group' => '`packages`.id'));
break;
}
}
示例2: search
public function search()
{
$methods = get_class_methods($this);
$sql = array();
foreach ($methods as $method) {
$matches = array();
if (preg_match('/([a-zA-z0-9_]+)_conditions$/', $method, $matches)) {
$retrun = call_user_func(array($this, $method));
if (!empty($return)) {
$sql[] = NimbleRecord::sanitize($return);
}
}
}
$conditions = implode(' ', $sql);
return Package::find_all(array('conditions' => $conditions));
}
示例3: Package
<?php
require_once "../initialise_files.php";
include_once "sessioninc.php";
$packages = Package::find_all();
$smarty->assign('packages', $packages);
if (isset($_GET['id']) && isset($_GET['action']) && $_GET['action'] == "delete") {
$package = new Package();
$package->id = (int) $_GET['id'];
if ($package->delete()) {
$session->message("<div class='success'>Package has been deleted.</div>");
redirect_to($_SERVER['PHP_SELF']);
die;
} else {
$message = "<div class='error'> Problem deleteing package</div>";
}
}
$html_title = SITE_NAME . " List Packages ";
$smarty->assign('lang', $lang);
$smarty->assign('message', $message);
$smarty->assign('rendered_page', $smarty->fetch('admin/list_packages.tpl'));
$smarty->display('admin/index.tpl');