本文整理汇总了PHP中Order::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::count方法的具体用法?PHP Order::count怎么用?PHP Order::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order::count方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
public function indexAction()
{
$userInfo = $this->session->get('userInfo');
//验证会员是否已登录
if (empty($userInfo)) {
$url = $this->url->get('user/login');
header("Location:{$url}");
exit;
}
$uid = $userInfo['id'];
//分页
$page = $this->request->get('page') ? $this->request->get('page') : 1;
$filter = array("uid={$uid}", 'order' => 'ctime desc');
//总数
$count = \Order::count($filter);
$limit = 5;
$filter['offset'] = ($page - 1) * $limit;
$filter['limit'] = $limit;
//查询订单信息
$userOrder = \Order::find($filter) ? \Order::find($filter)->toArray() : '';
//查询订单影片信息
foreach ($userOrder as &$val) {
$val['film'] = Film::findFirst('id=' . $val['film_id'])->toArray();
$val['film_heat'] = FilmHeat::findFirst('film_id=' . $val['film_id'])->toArray();
$schedule = FilmSchedule::findFirst('id=' . $val['schedule_id'])->toArray();
if ($schedule) {
$time = strtotime($schedule['starttime']);
$week_arr = array('日', '一', '二', '三', '四', '五', '六');
$val['film_schedule'] = date('n', $time) . '月' . date('j', $time) . '日 周' . $week_arr[date('w', $time)] . ' ' . date('H:i', $time);
} else {
$val['film_schedule'] = '';
}
}
$page_html = \ToolStr::GetPage($count, $limit);
$this->view->setVar('page_html', $page_html);
$this->view->setVar('userInfo', $userInfo);
$this->view->setVar('user_order', $userOrder);
$this->view->setVar('title', '会员中心');
}
示例2: listOrder
public function listOrder()
{
if (!Request::ajax()) {
return App::abort(404);
}
$admin_id = Auth::admin()->get()->id;
$start = Input::has('start') ? (int) Input::get('start') : 0;
$length = Input::has('length') ? Input::get('length') : 10;
$search = Input::has('search') ? Input::get('search') : [];
$orders = Order::with('billingAddress')->with('shippingAddress')->with('user')->select(DB::raw('id, user_id, billing_address_id, shipping_address_id, status, sum_sub_total, discount, tax, sum_tax, note,
(SELECT COUNT(*)
FROM notifications
WHERE notifications.item_id = orders.id
AND notifications.item_type = "Order"
AND notifications.admin_id = ' . $admin_id . '
AND notifications.read = 0 ) as new'));
if (!empty($search)) {
foreach ($search as $key => $value) {
if (empty($value)) {
continue;
}
if ($key == 'status') {
$orders->where($key, $value);
} else {
if ($key == 'full_name') {
$orders->whereHas('user', function ($query) use($value) {
$query->where(function ($q) use($value) {
$value = trim($value);
$arr_value = explode(' ', $value);
foreach ($arr_value as $key2 => $value2) {
$q->orWhere('first_name', 'like', '%' . $value2 . '%');
$q->orWhere('last_name', 'like', '%' . $value2 . '%');
}
});
});
} else {
if ($key == 'billing_address_id') {
$orders->whereHas('billing_address', function ($query) use($value) {
$query->where(function ($q) use($value) {
$value = trim($value);
$arr_value = explode(' ', $value);
foreach ($arr_value as $key2 => $value2) {
$q->orWhere('address1', 'like', '%' . $value2 . '%');
$q->orWhere('address2', 'like', '%' . $value2 . '%');
}
});
});
} else {
if ($key == 'shipping_address_id') {
$orders->whereHas('shipping_address', function ($query) use($value) {
$query->where(function ($q) use($value) {
$value = trim($value);
$arr_value = explode(' ', $value);
foreach ($arr_value as $key2 => $value2) {
$q->orWhere('address1', 'like', '%' . $value2 . '%');
$q->orWhere('address2', 'like', '%' . $value2 . '%');
}
});
});
} else {
$value = ltrim(rtrim($value));
$orders->where($key, 'like', '%' . $value . '%');
}
}
}
}
}
}
$order = Input::has('order') ? Input::get('order') : [];
if (!empty($order)) {
$columns = Input::has('columns') ? Input::get('columns') : [];
foreach ($order as $value) {
$column = $value['column'];
if (!isset($columns[$column]['name']) || empty($columns[$column]['name'])) {
continue;
}
$orders->orderBy($columns[$column]['name'], $value['dir'] == 'asc' ? 'asc' : 'desc');
}
}
$count = $orders->count();
if ($length > 0) {
$orders = $orders->skip($start)->take($length);
}
$arrOrders = $orders->get()->toArray();
$arrReturn = ['draw' => Input::has('draw') ? Input::get('draw') : 1, 'recordsTotal' => Order::count(), 'recordsFiltered' => $count, 'data' => []];
$arrRemoveNew = [];
if (!empty($arrOrders)) {
foreach ($arrOrders as $key => $order) {
$order['full_name'] = $order['user']['first_name'] . ' ' . $order['user']['last_name'];
if ($order['new']) {
$order['full_name'] .= '| <span class="badge badge-danger">new</span>';
$arrRemoveNew[] = $order['id'];
}
$order['billing_address'] = $order['billing_address']['address1'] . ' ' . $order['billing_address']['address2'];
$order['shipping_address'] = $order['shipping_address']['address1'] . ' ' . $order['shipping_address']['address2'];
$arrReturn['data'][] = array(++$start, $order['id'], $order['full_name'], $order['billing_address'], $order['shipping_address'], $order['status'], $order['sum_sub_total'], $order['discount'], $order['sum_tax'], $order['note'], htmlentities(nl2br($order['billing_address'])), htmlentities(nl2br($order['shipping_address'])));
}
}
if (!empty($arrRemoveNew)) {
Notification::whereIn('item_id', $arrRemoveNew)->where('item_type', 'Order')->where('admin_id', $admin_id)->update(['read' => 1]);
//.........这里部分代码省略.........
示例3: myOrders
public function myOrders($app)
{
if (!$app->user->isLoggedIn()) {
$app->output->redirect('/account/login');
}
$request = $app->router->flight->request();
$page = $request->query->p ?: 0;
$offset = $page * self::MAX_ORDERS_SHOWN;
$total = Order::count(array('conditions' => array('user_id = ?', $app->user->id))) / self::MAX_ORDERS_SHOWN;
$total = ceil($total);
if ($offset < 0 || $page > $total) {
$app->output->redirect('/account/orders');
}
// All of the orders made by a user
$orders = Order::find('all', array('conditions' => array('user_id = ?', $app->user->id), 'offset' => $offset, 'limit' => self::MAX_ORDERS_SHOWN, 'order' => 'updated_at DESC'));
if (empty($orders)) {
$app->output->alert('You have yet to make/receive any orders.');
}
$app->output->setTitle('Order History');
$app->output->addBreadcrumb('', 'CSGOShop');
$app->output->addBreadcrumb('account/orders', 'Order History');
$app->output->setActiveTab('account');
$app->output->render('account.history', ['orders' => $orders, 'page_num' => $page, 'total' => $total]);
}
示例4: list
// get some divs
if ($by_ajax && is_numeric($target) && preg_match('/get_.+_div/', $action)) {
include FrameFile::controller('order.get_div');
exit;
}
// 对订单的操作,通过表单post过来的
if ($action && $by_post && is_numeric($target)) {
include FrameFile::controller('order.control');
exit;
}
list($customer, $username, $factory) = _get('customer', 'username', 'factory');
$conds = array_merge($conds, compact('username', 'factory'));
$page['styles'][] = 'admin';
break;
default:
throw new Exception("unkown user type: {$user_type}");
break;
}
$conds['customer'] = $customer;
$per_page = 50;
$total = Order::count($conds);
$paging = new Paginate($per_page, $total);
$paging->setCurPage(_get('p') ?: 1);
$orders = Order::listOrder(array_merge(array('limit' => $per_page, 'offset' => $paging->offset()), $conds));
// we don't need these two lines
if (empty($orders)) {
$orders = array();
}
$matter = $view;
$view = 'board?master';
$page['scripts'][] = 'jquery.validate.min';
示例5: actionIndex
public function actionIndex()
{
$orderModel = new Order;
$mid = Yii::app()->session['myuserid'];
//计算代付款订单数量
$unpaycount = $orderModel->count(array(
'condition'=>'status=0',
'condition'=>"mid=$mid",
));
//输出当前账号订单信息
$criteria=new CDbCriteria;
$criteria->select = 'id,tid,sid,tattedcode,name,daynumber,departure,trackcode,createtime,status';
$criteria->condition = "mid=$mid and updatetime<>0";
$criteria->order = "createtime desc";
$count=$orderModel->count($criteria);
$pages=new CPagination($count);
$pages->pageSize=5;
$pages->applyLimit($criteria);
$orderinfo = $orderModel->findAll($criteria);
//查询当前账号信息
$mid = Yii::app()->session['myuserid'];
$memberModel = Member::model()->find(array(
'condition'=>"id=$mid",
));
//获取当前账号评论信息
$reviewsArr = $memberModel->Reviews;
//获取单个订单的信息
//$oneOrders = array();
$controerM = array();
$clentsArr = array();
$roomArr = array();
if(isset($_REQUEST['rute'])){
$temstr = explode('-',$_REQUEST['rute']);
if($temstr[0]=='v'){
$oid = intval($temstr[1]);
$orderModel = $orderModel->find(array(//单个订单信息
'select'=>'id,cid,name,daynumber,departure,aduit,child,trackcode,createtime,status',
'condition'=>"id=$oid and mid=$mid",
));
if($orderModel==null){
$this->render('404',array('msg'=>'该订单不存在!'));
exit;
}
//联系人信息
$cid = $orderModel->cid;
$controerM = Contacter::model()->findByPk($cid);//联系人信息
//参团人信息
$clentsArr = $orderModel->Clients;
//房间信息
$roomArr = $orderModel->Rooms;
}
}
$this->render('index',array(
'orderinfo'=>$orderinfo,
'unpaycount'=>$unpaycount,
'memberModel'=>$memberModel,
'reviewsArr'=>$reviewsArr,
'orderModel'=>$orderModel,
'controerM'=>$controerM,
'clentsArr'=>$clentsArr,
'roomArr'=>$roomArr,
'pages'=>$pages,
));
}
示例6: actiondevice
public function actiondevice()
{
$CModel = new Order;
$criteria=new CDbCriteria;
$start = '';
$stop = '';
//构造条件
if(isset($_POST['device'])){
switch ($_POST['type']){
case 1:
$criteria->addCondition("device=1");break;
case 2:
$criteria->addCondition("device=2");break;
default:
break;
}
if(!empty($_POST['start'])){
$start = $_POST['start'];
$mytimeteo = strtotime($mytime);
$criteria->addCondition("createtime>=$mytimeteo");
}
if(!empty($_POST['stop'])){
$stop = $_POST['stop'];
$mytimeteo = strtotime($mytime);
$criteria->addCondition("createtime<=$mytimeteo");
}
}
$criteria->addCondition("updatetime<>0");
//分页
$count=$CModel->count($criteria);
$pages=new CPagination($count);
$pages->pageSize=15;
$pages->applyLimit($criteria);
$calArr = $CModel->findAll($criteria);
$this->render('device',array(
'calArr'=>$calArr,
'pages'=>$pages,
'start'=>$start,
'stop'=>$stop,
));
}