本文整理汇总了PHP中Discount::count方法的典型用法代码示例。如果您正苦于以下问题:PHP Discount::count方法的具体用法?PHP Discount::count怎么用?PHP Discount::count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Discount
的用法示例。
在下文中一共展示了Discount::count方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionList
public function actionList()
{
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$model = new Discount();
$organID = Commonmodel::getOrganID();
//$organID=Yii::app()->user->id;
$criteria = new CDbCriteria();
//查询条件
$criteria->addCondition("UserID=:userID and OrganID=:organID ");
$criteria->params[':userID'] = Yii::app()->user->id;
$criteria->params[':organID'] = $organID;
//搜索条件
if ($_GET) {
$search['title'] = $_GET['title'];
$search['type'] = $_GET['type'];
$search['status'] = $_GET['status'];
$begintime = strtotime($_GET['dates']);
$search['dates'] = strtotime("{$_GET['dates']}+ 1 day");
if ($search) {
if ($search['title']) {
$criteria->addSearchCondition('Title', "{$search['title']}", "AND");
}
if (!empty($search['status']) || $search['status'] == 0) {
$criteria->addSearchCondition('Status', "{$search['status']}", "AND");
}
if (!empty($search['type']) || $search['type'] == 0) {
$criteria->addSearchCondition("Type", "{$search['type']}", "AND");
}
if (!empty($search['dates'])) {
$criteria->addBetweenCondition('CreateTime', $begintime, $search['dates'], "AND");
}
}
}
$criteria->order = "CreateTime DESC,ID DESC";
$count = $model->count($criteria);
// //分页类调用
$pages = new CPagination($count);
// //每页显示的行数
$pages->pageSize = $_GET['rows'];
$pages->applyLimit($criteria);
$model = $model->findAll($criteria);
// $model=$model->findAll('Status=:status',array(':status'=>'0'));
$data = array();
foreach ($model as $key => $value) {
$data[$key]['ID'] = $value['ID'];
$data[$key]['Title'] = $value["Title"];
$data[$key]['Content'] = $value['Content'];
// $data[$key]['Type'] = $value['Type'];
$data[$key]['TypeID'] = $value['Type'];
switch ($value['Type']) {
case 0:
$data[$key]['Type'] = '抵扣券';
break;
case 1:
$data[$key]['Type'] = '折扣券';
break;
case 2:
$data[$key]['Type'] = '其他';
break;
}
if ($value['Type'] == 0) {
$data[$key]['Rate'] = !empty($value['Rate']) ? $value['Rate'] : '无';
$data[$key]['Rate2'] = '减现' . $value['Rate'] . '元';
}
if ($value['Type'] == 1) {
$data[$key]['Rate'] = !empty($value['Rate']) ? $value['Rate'] : '无 ';
$data[$key]['Rate2'] = '打' . $value['Rate'] . '折';
}
if ($value['Type'] == 2) {
$data[$key]['Rate'] = $value['Rate'];
}
$data[$key]['StartTime'] = date('Y/m/d H:i:s', $value['StartTime']);
$data[$key]['EndTime'] = date('Y/m/d H:i:s', $value['EndTime']);
$data[$key]['CreateTime'] = date('Y/m/d H:i:s', $value['CreateTime']);
//$data[$key]['Rate']=$value['Rate'];
$data[$key]['EffectTime'] = date('Y/m/d', $value['StartTime']) . '-' . date('Y/m/d', $value['EndTime']);
if ($value['Status'] == 2) {
if ($value['EndTime'] < time()) {
$d = Discount::model()->updateByPk($value['ID'], array("Status" => 1));
}
}
switch ($value['Status']) {
case 0:
$data[$key]['Status'] = '未开启';
break;
case 1:
$data[$key]['Status'] = '已关闭';
break;
case 2:
$data[$key]['Status'] = '已开启';
break;
}
}
$rs = array('total' => $count, 'rows' => !empty($data) ? $data : array());
echo json_encode($rs);
}