本文整理汇总了PHP中CRequest::artificialLimit方法的典型用法代码示例。如果您正苦于以下问题:PHP CRequest::artificialLimit方法的具体用法?PHP CRequest::artificialLimit怎么用?PHP CRequest::artificialLimit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRequest
的用法示例。
在下文中一共展示了CRequest::artificialLimit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAutocompleteListWithPerms
/**
* Returns a list of objects for autocompleted fields
*
* @param int $permType Type of permission
* @param string $keywords Autocomplete seek fields
* @param array $where Where statements
* @param int $limit Limit the number of results
* @param array $ljoin Left join statements
* @param array $order Order by
*
* @return self[]
*/
function getAutocompleteListWithPerms($permType = PERM_READ, $keywords = null, $where = null, $limit = null, $ljoin = null, $order = null)
{
// Filter with permission
if (!$permType) {
return $this->getAutocompleteList($keywords, $where, $limit, $ljoin, $order);
}
// Load with no limit
$list = $this->getAutocompleteList($keywords, $where, null, $ljoin, $order);
self::filterByPerm($list, $permType);
// We simulate the MySQL LIMIT
if ($limit) {
$list = CRequest::artificialLimit($list, $limit);
}
return $list;
}
示例2: search
/**
* Search a product
*
* @param string $type The type of orders we are looking for [waiting|locked|pending|received|cancelled]
* @param string $keywords [optional]
* @param integer $limit = 30 [optional]
* @param array $where Where additionnal
*
* @return self[] The list of orders
*/
function search($type, $keywords = "", $limit = 30, $where = array())
{
global $g;
$leftjoin = array();
$leftjoin['product_order_item'] = 'product_order.order_id = product_order_item.order_id';
$leftjoin['product_order_item_reception'] = 'product_order_item.order_item_id = product_order_item_reception.order_item_id';
$leftjoin['product_reference'] = 'product_order_item.reference_id = product_reference.reference_id';
$leftjoin['product'] = 'product_reference.product_id = product.product_id';
// if keywords have been provided
if ($keywords) {
$societe = new CSociete();
$where_or = array();
// we seek among the societes
$where_societe_or = array();
foreach ($societe->getSeekables() as $field => $spec) {
$where_societe_or[] = "societe.{$field} LIKE '%{$keywords}%'";
}
$where_societe[] = implode(' OR ', $where_societe_or);
// we seek among the orders
foreach ($this->getSeekables() as $field => $spec) {
$where_or[] = "product_order.{$field} LIKE '%{$keywords}%'";
}
$where_or[] = 'product_order.societe_id ' . CSQLDataSource::prepareIn(array_keys($societe->loadList($where_societe)));
$where[] = implode(' OR ', $where_or);
}
$orderby = 'product_order.date_ordered DESC, product_order_item_reception.date DESC';
$where['product_order.deleted'] = " = 0";
$where['product_order.cancelled'] = " = 0";
$where['product_order.locked'] = " = 0";
$where['product_order.date_ordered'] = "IS NULL";
$where['product_order.received'] = " != '1'";
// Exclude return orders (Bon de retour)
$query = "!= % OR product_order.comments IS NULL";
$where['product_order.comments'] = $this->_spec->ds->prepare($query, CProductOrder::$_return_form_label);
switch ($type) {
case 'waiting':
break;
case 'locked':
$where['product_order.locked'] = " = 1";
break;
case 'pending':
$where['product_order.locked'] = " = 1";
$where['product_order.date_ordered'] = "IS NOT NULL";
break;
case 'received':
$where['product_order.locked'] = " = 1";
$where['product_order.date_ordered'] = "IS NOT NULL";
$where['product_order.received'] = " = '1'";
break;
default:
case 'cancelled':
$where['product_order.cancelled'] = " = 1";
unset($where['product_order.locked']);
unset($where['product_order.received']);
unset($where['product_order.date_ordered']);
break;
}
$where['product_order.group_id'] = " = '" . CProductStockGroup::getHostGroup() . "'";
$old_limit = $limit;
if ($type === 'pending') {
$limit = 200;
}
$groupby = "product_order.order_id";
/** @var self[] $orders_list */
$orders_list = $this->loadList($where, $orderby, $limit, $groupby, $leftjoin);
// bons de facturation seulement
if ($type === 'pending') {
foreach ($orders_list as $_id => $_order) {
if (!$_order->containsRenewalLines()) {
unset($orders_list[$_id]);
}
}
$this->_search_count = count($orders_list);
$orders_list = CRequest::artificialLimit($orders_list, $old_limit);
} else {
$this->_search_count = count($this->countMultipleList($where, null, $groupby, $leftjoin));
}
/*if ($type === 'pending') {
$list = array();
foreach ($orders_list as $_order) {
if ($_order->countReceivedItems() < $_order->countBackRefs("order_items")) {
$list[] = $_order;
}
}
$orders_list = $list;
}
else if ($type === 'received') {
$list = array();
foreach ($orders_list as $_order) {
//.........这里部分代码省略.........