本文整理匯總了PHP中Core\Helper\Utility\Validator::min方法的典型用法代碼示例。如果您正苦於以下問題:PHP Validator::min方法的具體用法?PHP Validator::min怎麽用?PHP Validator::min使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Core\Helper\Utility\Validator
的用法示例。
在下文中一共展示了Validator::min方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: Search
public function Search($f3)
{
/**
* 我們使用搜索模塊做搜索操作
*/
$searchFieldSelector = 'og.*, oi.system_id, oi.consignee';
global $smarty;
// 參數驗證
$validator = new Validator($f3->get('GET'));
$pageNo = $validator->digits()->min(0)->validate('pageNo');
$pageSize = $validator->digits()->min(0)->validate('pageSize');
// 設置缺省值
$pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
$pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 10;
// shippingStatus, 0 全部,1 已發貨,2 未發貨
$shippingStatus = $validator->digits()->min(1)->validate('shippingStatus');
//訂單表單查詢
$searchFormQuery = array();
$searchFormQuery['og.order_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('order_id');
$searchFormQuery['og.rec_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('rec_id');
$searchFormQuery['og.goods_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id');
$searchFormQuery['og.goods_name'] = $validator->validate('goods_name');
$searchFormQuery['oi.order_sn'] = $validator->validate('order_sn');
$order_goods_status = $validator->min(0)->filter('ValidatorIntValue')->validate('order_goods_status');
if (null == $order_goods_status) {
// 選擇 請求退款、退款中、退款完成 狀態的訂單
$searchFormQuery['og.order_goods_status'] = array('>', OrderGoodsService::OGS_PAY);
} else {
$searchFormQuery['og.order_goods_status'] = $order_goods_status;
}
$searchFormQuery['oi.consignee'] = $validator->validate('consignee');
$searchFormQuery['oi.mobile'] = $validator->validate('mobile');
$searchFormQuery['oi.address'] = $validator->validate('address');
$searchFormQuery['oi.postscript'] = $validator->validate('postscript');
$searchFormQuery['og.memo'] = $validator->validate('memo');
//退款時間
$refundTimeStartStr = $validator->validate('refund_time_start');
$refundTimeStart = Time::gmStrToTime($refundTimeStartStr) ?: null;
$refundTimeEndStr = $validator->validate('refund_time_end');
$refundTimeEnd = Time::gmStrToTime($refundTimeEndStr) ?: null;
$searchFormQuery['og.refund_time'] = array($refundTimeStart, $refundTimeEnd);
//完成時間
$refundFinishTimeStartStr = $validator->validate('refund_finish_time_start');
$refundFinishTimeStart = Time::gmStrToTime($refundFinishTimeStartStr) ?: null;
$refundFinishTimeEndStr = $validator->validate('refund_finish_time_end');
$refundFinishTimeEnd = Time::gmStrToTime($refundFinishTimeEndStr) ?: null;
$searchFormQuery['og.refund_finish_time'] = array($refundFinishTimeStart, $refundFinishTimeEnd);
if (!$this->validate($validator)) {
goto out_display;
}
// 構造查詢條件
$authSupplierUser = AuthHelper::getAuthUser();
// 供貨商隻能查看自己商品對應的訂單
$searchFormQuery['og.suppliers_id'] = intval($authSupplierUser['suppliers_id']);
// 構造查詢條件
$searchParamArray = array();
// 用戶取消的訂單商品我們就不再顯示了
$searchParamArray[] = array(QueryBuilder::buildNotInCondition('oi.order_status', array(OrderBasicService::OS_CANCELED, OrderBasicService::OS_INVALID), \PDO::PARAM_INT));
if (1 == $shippingStatus) {
// 1 未發貨
$searchParamArray[] = array('og.shipping_id = 0');
} elseif (2 == $shippingStatus) {
// 2 已發貨
$searchParamArray[] = array('og.shipping_id <> 0');
} else {
// do nothing
}
// 表單查詢
$searchParamArray = array_merge($searchParamArray, QueryBuilder::buildSearchParamArray($searchFormQuery));
// 使用哪個搜索模塊
$searchModule = SearchHelper::Module_OrderGoodsOrderInfo;
// 查詢訂單列表
$totalCount = SearchHelper::count($searchModule, $searchParamArray);
if ($totalCount <= 0) {
// 沒訂單,可以直接退出了
goto out_display;
}
// 頁數超過最大值,返回第一頁
if ($pageNo * $pageSize >= $totalCount) {
RouteHelper::reRoute($this, '/Order/Refund/Search');
}
// 查詢訂單列表
$orderGoodsArray = SearchHelper::search($searchModule, $searchFieldSelector, $searchParamArray, array(array('og.order_id', 'desc')), $pageNo * $pageSize, $pageSize);
// 訂單的支付狀態顯示
foreach ($orderGoodsArray as &$orderGoodsItem) {
$orderGoodsItem['order_goods_status_desc'] = OrderGoodsService::$orderGoodsStatusDesc[$orderGoodsItem['order_goods_status']];
}
// 前麵用了引用,這裏一定要清除,防止影響後麵的數據
unset($orderGoodsItem);
// 給模板賦值
$smarty->assign('totalCount', $totalCount);
$smarty->assign('pageNo', $pageNo);
$smarty->assign('pageSize', $pageSize);
$smarty->assign('orderGoodsArray', $orderGoodsArray);
out_display:
$smarty->display('order_refund_search.tpl');
}
示例2: Search
public function Search($f3)
{
// 權限檢查
$this->requirePrivilege('manage_order_goods_search');
/**
* 我們使用搜索模塊做搜索操作
*/
$searchFieldSelector = 'og.*, oi.user_id, oi.system_id, oi.kefu_user_id, oi.kefu_user_name, oi.kefu_user_rate';
global $smarty;
// 參數驗證
$validator = new Validator($f3->get('GET'));
$pageNo = $validator->digits()->min(0)->validate('pageNo');
$pageSize = $validator->digits()->min(0)->validate('pageSize');
// 設置缺省值
$pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
$pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 10;
// shippingStatus, 0 全部,1 已發貨,2 未發貨
$shippingStatus = $validator->digits()->min(1)->validate('shippingStatus');
//訂單表單查詢
$searchFormQuery = array();
$searchFormQuery['og.order_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('order_id');
$searchFormQuery['og.rec_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('rec_id');
$searchFormQuery['og.goods_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id');
$searchFormQuery['og.goods_name'] = $validator->validate('goods_name');
$searchFormQuery['oi.order_sn'] = $validator->validate('order_sn');
$searchFormQuery['oi.pay_no'] = $validator->validate('pay_no');
$order_goods_status = $validator->min(-1)->filter('ValidatorIntValue')->validate('order_goods_status');
if ($order_goods_status >= 0) {
$searchFormQuery['og.order_goods_status'] = $order_goods_status;
}
$searchFormQuery['oi.consignee'] = $validator->validate('consignee');
$searchFormQuery['oi.mobile'] = $validator->validate('mobile');
$searchFormQuery['oi.address'] = $validator->validate('address');
$searchFormQuery['oi.postscript'] = $validator->validate('postscript');
$searchFormQuery['og.memo'] = $validator->validate('memo');
$searchFormQuery['oi.kefu_user_id'] = $validator->filter('ValidatorIntValue')->validate('kefu_user_id');
$searchFormQuery['og.goods_admin_user_id'] = $validator->filter('ValidatorIntValue')->validate('goods_admin_user_id');
//下單時間
$createTimeStartStr = $validator->validate('create_time_start');
$createTimeStart = Time::gmStrToTime($createTimeStartStr) ?: null;
$createTimeEndStr = $validator->validate('create_time_end');
$createTimeEnd = Time::gmStrToTime($createTimeEndStr) ?: null;
$searchFormQuery['og.create_time'] = array($createTimeStart, $createTimeEnd);
//付款時間
$payTimeStartStr = $validator->validate('pay_time_start');
$payTimeStart = Time::gmStrToTime($payTimeStartStr) ?: null;
$payTimeEndStr = $validator->validate('pay_time_end');
$payTimeEnd = Time::gmStrToTime($payTimeEndStr) ?: null;
$searchFormQuery['oi.pay_time'] = array($payTimeStart, $payTimeEnd);
if (!$this->validate($validator)) {
goto out_display;
}
// 構造查詢條件
$searchParamArray = array();
// 用戶取消的訂單商品我們就不再顯示了
$searchParamArray[] = array(QueryBuilder::buildNotInCondition('oi.order_status', array(OrderBasicService::OS_CANCELED, OrderBasicService::OS_INVALID), \PDO::PARAM_INT));
if (1 == $shippingStatus) {
// 1 未發貨
$searchParamArray[] = array('og.shipping_id = 0');
} elseif (2 == $shippingStatus) {
// 2 已發貨
$searchParamArray[] = array('og.shipping_id <> 0');
} else {
// do nothing
}
// 用戶查詢,目前支持 用戶名、郵箱 查詢
$user_name = $validator->validate('user_name');
$email = $validator->validate('email');
if (!empty($user_name) || !empty($email)) {
$userQuery = array();
$userQuery['user_name'] = $user_name;
$userQuery['email'] = $email;
$userBasicService = new UserBasicService();
$queryUserArray = $userBasicService->_fetchArray('users', 'user_id', QueryBuilder::buildQueryCondArray($userQuery), array('order' => 'user_id desc'), 0, 1000);
unset($userBasicService);
if (empty($queryUserArray)) {
$this->addFlashMessage('搜索的用戶不存在');
} else {
$userIdArray = array();
foreach ($queryUserArray as $queryUser) {
$userIdArray[] = $queryUser['user_id'];
}
if (!empty($userIdArray)) {
$searchParamArray[] = array(QueryBuilder::buildInCondition('oi.user_id', $userIdArray, \PDO::PARAM_INT));
}
unset($userIdArray);
unset($queryUserArray);
}
}
$utmSource = $validator->validate('utm_source');
if ('SELF' == $utmSource) {
$searchParamArray[] = array('orf.utm_source is null');
} else {
$searchFormQuery['orf.utm_source'] = array('=', $utmSource);
}
$utmMedium = $validator->validate('utm_medium');
if ('SELF' == $utmMedium) {
$searchParamArray[] = array('orf.utm_medium is null');
} else {
$searchFormQuery['orf.utm_medium'] = array('=', $utmMedium);
//.........這裏部分代碼省略.........
示例3: Search
public function Search($f3)
{
/**
* 我們使用搜索模塊做搜索操作
*/
$searchFieldSelector = 'og.*, oi.pay_time, oi.system_id';
global $smarty;
// 參數驗證
$validator = new Validator($f3->get('GET'));
$pageNo = $validator->digits()->min(0)->validate('pageNo');
$pageSize = $validator->digits()->min(0)->validate('pageSize');
// 設置缺省值
$pageNo = isset($pageNo) && $pageNo > 0 ? $pageNo : 0;
$pageSize = isset($pageSize) && $pageSize > 0 ? $pageSize : 10;
// shippingStatus, 0 全部,1 已發貨,2 未發貨
$shippingStatus = $validator->digits()->min(1)->validate('shippingStatus');
//表單查詢
$searchFormQuery = array();
$searchFormQuery['og.order_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('order_id');
$searchFormQuery['og.rec_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('rec_id');
$searchFormQuery['og.goods_id'] = $validator->digits()->min(1)->filter('ValidatorIntValue')->validate('goods_id');
$searchFormQuery['og.order_goods_status'] = $validator->min(1)->filter('ValidatorIntValue')->validate('order_goods_status');
$searchFormQuery['og.goods_sn'] = $validator->validate('goods_sn');
$searchFormQuery['oi.consignee'] = $validator->validate('consignee');
$searchFormQuery['oi.mobile'] = $validator->validate('mobile');
$searchFormQuery['oi.address'] = $validator->validate('address');
$searchFormQuery['oi.postscript'] = $validator->validate('postscript');
$searchFormQuery['og.memo'] = $validator->validate('memo');
//下單時間
$addTimeStartStr = $validator->validate('add_time_start');
$addTimeStart = Time::gmStrToTime($addTimeStartStr) ?: null;
$addTimeEndStr = $validator->validate('add_time_end');
$addTimeEnd = Time::gmStrToTime($addTimeEndStr) ?: null;
$searchFormQuery['oi.add_time'] = array($addTimeStart, $addTimeEnd);
//付款時間
$payTimeStartStr = $validator->validate('pay_time_start');
$payTimeStart = Time::gmStrToTime($payTimeStartStr) ?: null;
$payTimeEndStr = $validator->validate('pay_time_end');
$payTimeEnd = Time::gmStrToTime($payTimeEndStr) ?: null;
$searchFormQuery['oi.pay_time'] = array($payTimeStart, $payTimeEnd);
if (!$this->validate($validator)) {
goto out_display;
}
// 構造查詢條件
$authSupplierUser = AuthHelper::getAuthUser();
// 供貨商隻能查看自己商品對應的訂單
$searchFormQuery['og.suppliers_id'] = intval($authSupplierUser['suppliers_id']);
$searchParamArray = array();
// 供貨商隻能查看已經付款的訂單
$searchParamArray[] = array('og.order_goods_status > 0');
if (1 == $shippingStatus) {
// 1 未發貨
$searchParamArray[] = array('og.shipping_id = 0');
} elseif (2 == $shippingStatus) {
// 2 已發貨
$searchParamArray[] = array('og.shipping_id <> 0');
} else {
// do nothing
}
// 表單查詢
$searchParamArray = array_merge($searchParamArray, QueryBuilder::buildSearchParamArray($searchFormQuery));
// 查詢訂單列表
$totalCount = SearchHelper::count(SearchHelper::Module_OrderGoodsOrderInfo, $searchParamArray);
if ($totalCount <= 0) {
// 沒訂單,可以直接退出了
goto out_display;
}
// 頁數超過最大值,返回第一頁
if ($pageNo * $pageSize >= $totalCount) {
RouteHelper::reRoute($this, '/Order/Goods/Search');
}
// 訂單列表
$orderGoodsArray = SearchHelper::search(SearchHelper::Module_OrderGoodsOrderInfo, $searchFieldSelector, $searchParamArray, array(array('oi.pay_time', 'desc')), $pageNo * $pageSize, $pageSize);
// 訂單的支付狀態顯示
foreach ($orderGoodsArray as &$orderGoodsItem) {
$orderGoodsItem['order_goods_status_desc'] = OrderGoodsService::$orderGoodsStatusDesc[$orderGoodsItem['order_goods_status']];
}
// 前麵用了引用,這裏一定要清除,防止影響後麵的數據
unset($orderGoodsItem);
// 給模板賦值
$smarty->assign('totalCount', $totalCount);
$smarty->assign('pageNo', $pageNo);
$smarty->assign('pageSize', $pageSize);
$smarty->assign('orderGoodsArray', $orderGoodsArray);
out_display:
$smarty->display('order_goods_search.tpl');
}