本文整理汇总了PHP中RedBeanPHP\R::count方法的典型用法代码示例。如果您正苦于以下问题:PHP R::count方法的具体用法?PHP R::count怎么用?PHP R::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\R
的用法示例。
在下文中一共展示了R::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$perPage = 999999;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$where = [];
$where[] = 1;
$queryParam = [];
if (!empty($_GET['geo_id'])) {
$where[] = "geo_id = ?";
$queryParam[] = $_GET['geo_id'];
}
$where = implode(" AND ", $where);
$queryParam[] = $start;
$queryParam[] = $perPage;
$items = R::getAll('SELECT * FROM contactdealer WHERE ' . $where . ' LIMIT ?,?', $queryParam);
//$items = R::find('contactdealer', 'LIMIT ?,?', [$start, $perPage]);
$count = R::count('contactdealer', $where, array_slice($queryParam, 0, -2));
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
// $itemsExport = R::exportAll($items);
$this->builds($items);
header('Content-Type: application/json');
echo json_encode(['items' => $items, 'page' => $page, 'maxPage' => $maxPage, 'total' => $count], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
示例2: index
public function index()
{
$perPage = 999999;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$where = [];
$where[] = 1;
$queryParam = [];
if (!empty($_GET['type'])) {
$where[] = "type = ?";
$queryParam[] = $_GET['type'];
}
if (!empty($_GET['porcelain_type'])) {
$where[] = "porcelain_type = ?";
$queryParam[] = $_GET['porcelain_type'];
}
if (!empty($_GET['size'])) {
$where[] = "size = ?";
$queryParam[] = $_GET['size'];
}
if (!empty($_GET['size_unit'])) {
$where[] = "size_unit = ?";
$queryParam[] = $_GET['size_unit'];
}
if (!empty($_GET['style'])) {
$where[] = "style = ?";
$queryParam[] = $_GET['style'];
}
if (!empty($_GET['company'])) {
$where[] = "company = ?";
$queryParam[] = $_GET['company'];
}
if (!empty($_GET['is_group'])) {
$where[] = "company = ?";
$queryParam[] = $_GET['company'];
}
if (!empty($_GET['pattern_id'])) {
$pattern = R::findOne("room_pattern", "id=?", [$_GET['pattern_id']]);
if (isset($pattern["product_use"])) {
$ids = trim($pattern["product_use"], ",");
$ids = explode(",", $ids);
} else {
$ids = [0];
}
$where[] = "id IN (" . R::genSlots($ids) . ")";
$queryParam = array_merge($queryParam, $ids);
}
$where = implode(" AND ", $where);
$queryParam[] = $start;
$queryParam[] = $perPage;
$items = R::getAll('SELECT product.* FROM product WHERE ' . $where . ' ORDER BY is_hot DESC, is_new DESC, created_at DESC LIMIT ?,?', $queryParam);
$count = R::count('product', $where, array_slice($queryParam, 0, -2));
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
// $itemsExport = R::exportAll($items);
$this->builds($items);
header('Content-Type: application/json');
echo json_encode(['items' => $items, 'page' => $page, 'maxPage' => $maxPage, 'total' => $count], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
示例3: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$items = R::find('user', 'level=2 LIMIT ?,?', [$start, $perPage]);
$count = R::count('user');
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$this->slim->render("user/list.php", ['items' => $items, 'page' => $page, 'maxPage' => $maxPage]);
}
示例4: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$items = R::find('account', 'email IS NOT NULL LIMIT ?,?', [$start, $perPage]);
$count = R::count('account', 'email IS NOT NULL');
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$itemsExport = R::exportAll($items);
$this->builds($itemsExport);
$this->slim->render("user/list.php", ['items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage]);
}
示例5: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$items = R::find('news', ' ORDER BY sort_order LIMIT ?,?', [$start, $perPage]);
$itemsAll = R::find('news', 'ORDER BY sort_order');
$itemsAll = R::exportAll($items);
$count = R::count('news');
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$this->slim->render("news/list.php", ['items' => $items, 'itemsAll' => $itemsAll, 'page' => $page, 'maxPage' => $maxPage]);
}
示例6: index
public function index($roomId)
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$room = R::findOne('room', 'id = ?', [$roomId]);
$items = R::find('room_pattern', 'room_id = ? LIMIT ?,?', [$roomId, $start, $perPage]);
$count = R::count('room_pattern', 'room_id = ?', [$roomId]);
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$itemsExport = R::exportAll($items);
$this->builds($itemsExport);
$this->slim->render("room/pattern/list.php", ['room' => $room, 'items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage]);
}
示例7: validate
public function validate()
{
$this->errors = [];
$this->error = false;
$this->isValid = true;
if (empty($this->attr['name'])) {
$this->pushError("name empty");
}
$id = @$this->attr["id"] ? $this->attr["id"] : 0;
if (R::count("room", "name = ? AND id != ?", [$this->attr["name"], $id]) > 0) {
$this->pushError("Duplicate name " . $this->attr["name"]);
}
return !$this->error;
}
示例8: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$items = R::find('room', 'LIMIT ?,?', [$start, $perPage]);
$count = R::count('room');
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$itemsExport = R::exportAll($items);
$this->builds($itemsExport);
header('Content-Type: application/json');
echo json_encode(['items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage, 'total' => $count], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
示例9: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$items = R::find('contactdealer', 'LIMIT ?,?', [$start, $perPage]);
$count = R::count('contactdealer');
foreach ($items as &$item) {
$item->ownProvince = R::getRow('SELECT * FROM provinces WHERE province_id=?', [$item->province_id]);
$item->ownGeography = R::getRow('SELECT * FROM geography WHERE geo_id=?', [$item->geo_id]);
// var_dump($item); exit();
}
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$this->slim->render("contactdealer/list.php", ['items' => $items, 'page' => $page, 'maxPage' => $maxPage]);
}
示例10: CreateInitialAdmin
public static function CreateInitialAdmin($container)
{
if (!R::count('user')) {
$admin = R::dispense('user');
$admin->username = 'admin';
$admin->is_admin = true;
$admin->is_active = true;
$admin->name = 'Anonymous';
$admin->image = '';
$admin->logins = 0;
$admin->last_login = null;
$admin->password_hash = password_hash('admin', PASSWORD_BCRYPT);
$admin->active_token = null;
R::store($admin);
}
}
示例11: index
public function index()
{
$perPage = 999999;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$where = [];
$whereParam = [];
if (!empty($_GET['room_id'])) {
$where[] = "room_id = ?";
$whereParam[] = $_GET['room_id'];
}
$whereString = implode("AND", $where);
$items = R::find('room_pattern', $whereString . ' LIMIT ?,?', array_merge($whereParam, [$start, $perPage]));
$count = R::count('room_pattern', $whereString, $whereParam);
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$itemsExport = R::exportAll($items);
$this->builds($itemsExport);
header('Content-Type: application/json');
echo json_encode(['items' => $itemsExport, 'page' => $page, 'maxPage' => $maxPage, 'total' => $count], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
示例12: comicDetails
/**
* @RequestMapping(url="account/comic/{comic_id}/{vol}",type="template",auth=true)
* @RequestParams(true)
* @Role(USER)
* @Role(ADMIN)
*/
function comicDetails($model, $comic_id = null, $action = null, $title = null, $vol = 1)
{
Service::DBSetup();
$comic = R::load("comic", $comic_id);
if ($action == "add_chapter" && $title !== null) {
$chapter = R::dispense("chapter");
$chapter->title = $title;
$chapter->uid = $this->user->uid;
$chapter->vol = $vol;
$chapter->comic = $comic;
$chapter->inorder = R::count("chapter", "comic_id = :comic_id AND vol = :vol", array("comic_id" => $comic_id, "vol" => $vol));
$chapter->time = microtime(true);
R::store($chapter);
}
$chapters = R::find("chapter", "comic_id = :comic_id AND vol = :vol", array("comic_id" => $comic_id, "vol" => $vol));
//print_r($comic);
$model->assign("comic", $comic);
$model->assign("chapters", $chapters);
$model->assign("user", $this->user);
return "member/comic";
}
示例13: checkOut
public static function checkOut($number, Publisher $publisher)
{
if (R::count('record', ' number = :number AND isnull(`in`) ', ['number' => $number]) > 0) {
return null;
}
$territoryBean = R::findOne('territory', ' number = :number ', ['number' => $number]);
if ($territoryBean === null) {
return null;
}
$bean = R::dispense('record');
$bean->number = $number;
$bean->out = time();
$bean->in = null;
$bean->checkOutBy = App::user()->id;
$record = new Record($number, $bean);
$territoryBean->sharedRecordList[] = $bean;
$publisherBean = $publisher->bean();
$publisherBean->ownRecordList[] = $bean;
R::storeAll([$bean, $territoryBean, $publisherBean]);
$publisher->records[] = $record;
return $record;
}
示例14: search
public function search()
{
$page = $this->getAttr("page");
$perPage = $this->getAttr("perPage");
$start = ($page - 1) * $perPage;
$query = "";
$bindParam = [];
$keyword = $this->getAttr("keyword");
$keyword = trim($keyword);
if (!empty($keyword)) {
$query .= "first_name LIKE :keyword OR last_name LIKE :keyword";
$bindParam["keyword"] = '%' . $keyword . '%';
}
$this->count = R::count('employee', $query, $bindParam);
$page = floor($this->count / $perPage);
$this->maxPage = $page + ($this->count % $perPage == 0 ? 0 : 1);
$query .= " LIMIT :start,:perPage";
$bindParam["start"] = $start;
$bindParam["perPage"] = $perPage;
$this->items = R::find('employee', $query, $bindParam);
$this->injectsUser($this->items);
}
示例15: index
public function index()
{
$perPage = 10;
$page = @$_GET['page'] ? $_GET['page'] : 1;
$start = ($page - 1) * $perPage;
$where = [];
$where[] = 1;
$queryParam = [];
if (!empty($_GET['type'])) {
$where[] = "type = ?";
$queryParam[] = $_GET['type'];
}
if (!empty($_GET['size'])) {
$where[] = "size = ?";
$queryParam[] = $_GET['size'];
}
if (!empty($_GET['style'])) {
$where[] = "style = ?";
$queryParam[] = $_GET['style'];
}
if (!empty($_GET['company'])) {
$where[] = "company = ?";
$queryParam[] = $_GET['company'];
}
$where = implode(" AND ", $where);
$queryParam[] = $start;
$queryParam[] = $perPage;
$items = R::getAll('SELECT * FROM product WHERE ' . $where . ' ORDER BY is_hot DESC, is_new DESC, created_at DESC LIMIT ?,?', $queryParam);
$count = R::count('product', $where, array_slice($queryParam, 0, -2));
$maxPage = floor($count / $perPage) + ($count % $perPage == 0 ? 0 : 1);
$form = [];
$form["type"] = @$_GET["type"] ?: "";
$form["size"] = @$_GET["size"] ?: "";
$form["style"] = @$_GET["style"] ?: "";
$form["company"] = @$_GET["company"] ?: "";
$this->slim->render("product/list.php", ['items' => $items, 'page' => $page, 'maxPage' => $maxPage, 'form' => $form]);
}