本文整理汇总了PHP中Collection::Query方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::Query方法的具体用法?PHP Collection::Query怎么用?PHP Collection::Query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collection
的用法示例。
在下文中一共展示了Collection::Query方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCounts
public static function updateCounts()
{
$cats = new self();
foreach ($cats->simpleSelect() as $cat) {
$nb = Collection::Query(PostsModel::TABLE)->whereEq(PostsModel::CATEGORY_ID, $cat->getId())->getCount();
$cat->set(self::POST_COUNT, $nb);
$cat->save();
}
}
示例2: fromPost
public static function fromPost($id)
{
$col = Collection::Query(self::TABLE)->Select(self::USERNAME, self::CONTENT, self::CREATED, self::MAIL)->WhereEq(self::POST_ID, $id)->orderByDesc(self::CREATED);
$list = array();
foreach ($col->getValues(isset($_GET["p"]) ? intval($_GET["p"]) : 0) as $row) {
$row["gid"] = md5($row["mail"]);
unset($row["mail"]);
$list[] = $row;
}
return $list;
}
示例3: get_user_list
protected function get_user_list($r)
{
Input::ensureRequest($r, array("id"));
$id = $r["id"];
$cats = new UsersModel();
$cat = $cats->getBy(UsersModel::USERNAME, $id);
$col = Collection::Query($this->model->getTableName())->SelectAs($this->model->getField($this->model->getPrimaryField())->getFullName(), self::ID)->leftJoin(CategoriesModel::TABLE, CategoriesModel::TABLE . "." . CategoriesModel::ID . "=" . PostsModel::TABLE . "." . PostsModel::CATEGORY_ID)->SelectAs(CategoriesModel::TABLE . "." . CategoriesModel::NAME, "catname")->SelectAs(CategoriesModel::TABLE . "." . CategoriesModel::SLUG, "catslug")->leftJoin(UsersModel::TABLE, UsersModel::TABLE . "." . UsersModel::ID . "=" . PostsModel::TABLE . "." . PostsModel::USER_ID)->orderByDesc(PostsModel::CREATED)->SelectAs(UsersModel::TABLE . "." . UsersModel::USERNAME, "username")->whereEq(PostsModel::USER_ID, $cat->get("id"))->limit($this->options["limit"]);
$this->filterList($col);
if (isset($_GET["q"]) && strlen($_GET["q"]) > 0) {
$col->filter($_GET["q"]);
}
$list = array();
foreach ($col->getValues(isset($_GET["p"]) ? intval($_GET["p"]) : 0) as $row) {
$list[] = $this->list_values($row);
}
Output::success(array("list" => $list));
}