本文整理汇总了PHP中Am_Query::addOrderRaw方法的典型用法代码示例。如果您正苦于以下问题:PHP Am_Query::addOrderRaw方法的具体用法?PHP Am_Query::addOrderRaw怎么用?PHP Am_Query::addOrderRaw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Am_Query
的用法示例。
在下文中一共展示了Am_Query::addOrderRaw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createGrid
public function createGrid()
{
$this->view->headScript()->appendFile(REL_ROOT_URL . "/application/default/views/public/js/jquery/jquery.json.js");
$this->view->headScript()->appendScript($this->getJs());
$table = $this->getDi()->savedFormTable;
$ds = new Am_Query($table);
$ds->addWhere('`type` in (?a)', array_keys($table->getTypeDefs()));
$ds->addOrderRaw("`type`='signup' DESC");
$grid = new Am_Grid_Editable('_s', ___("Forms Editor"), $ds, $this->_request, $this->view);
$grid->setForm(array($this, 'createForm'));
$grid->setRecordTitle(' ');
//$grid->addGridField(new Am_Grid_Field('saved_form_id', '#', true, '', null, '5%'));
$grid->addGridField(SavedForm::D_SIGNUP, ___('Default Signup'), false)->setWidth('5%')->setRenderFunction(array($this, 'renderDefault'));
$grid->addGridField(SavedForm::D_MEMBER, ___('Default for Members'), false)->setWidth('5%')->setRenderFunction(array($this, 'renderDefault'));
$existingTypes = $this->getDi()->savedFormTable->getExistingTypes();
$grid->actionGet('edit')->setTarget('_top');
$grid->actionDelete('insert');
foreach ($this->getDi()->savedFormTable->getTypeDefs() as $type => $typeDef) {
if (!empty($typeDef['isSingle']) && in_array($type, $existingTypes)) {
continue;
}
$grid->actionAdd(new Am_Grid_Action_Insert('insert-' . $type))->addUrlParam('type', $type)->setTitle(___('New %s', $typeDef['title']));
}
$grid->addCallback(Am_Grid_Editable::CB_BEFORE_SAVE, array($this, 'beforeSave'));
$grid->addGridField(new Am_Grid_Field('type', ___('Type')));
$grid->addGridField(new Am_Grid_Field('title', ___('Title')));
$grid->addGridField(new Am_Grid_Field('comment', ___('Comment')));
$grid->addGridField(new Am_Grid_Field('code', ___('Code')));
$grid->addGridField(new Am_Grid_Field('url', ___('URL')))->setRenderFunction(array($this, 'renderUrl'));
$grid->actionGet('delete')->setIsAvailableCallback(create_function('$record', 'return $record->canDelete();'));
return $grid;
}
示例2: createQuery
/**
* return query object with category filter applied if specified
* if parameters === 0, it selects products not assigned to any categories
* if parameter === null, it selects products regardless of categories
* @param int $product_category_id
* @param bool $include_hidden Include products from hidden categories.
* @return Am_Query
*/
function createQuery($product_category_id = null, $include_hidden = true)
{
$q = new Am_Query($this, 'p');
$q->addOrderRaw('0+p.sort_order')->addOrder('title');
$q->addWhere('p.is_disabled=0');
if ($product_category_id > 0) {
$q->innerJoin('?_product_product_category', 'ppc', 'ppc.product_id = p.product_id AND ppc.product_category_id=' . intval($product_category_id));
} elseif ((string) $product_category_id === '0') {
$q->leftJoin('?_product_product_category', 'ppc', 'ppc.product_id = p.product_id')->addHaving('count(ppc.product_category_id)=0');
} elseif (!$include_hidden) {
$q->leftJoin('?_product_product_category', 'ppc', 'ppc.product_id = p.product_id')->leftJoin('?_product_category', 'pc', 'pc.product_category_id = ppc.product_category_id')->addHaving('sum(if(pc.code>"", 1, 0)) =0');
}
return $q;
}
示例3: _getBaseQuery
/**
* @return Am_Query
*/
protected function _getBaseQuery($joinConditions = "")
{
if ($joinConditions) {
$joinConditions = "(" . $joinConditions . ") AND ";
}
$q = new Am_Query($this, 'r');
$q->clearFields();
$q->addField('DISTINCT r.resource_id', 'resource_id');
$q->addField('resource_type', 'resource_type');
$q->addField("fn", 'fn');
$q->addField("id", 'fn_id');
$q->leftJoin("?_access_cache", "c", "\n {$joinConditions} \n (((c.fn = r.fn) AND (c.id = r.id)) OR (r.fn='product_category_id' AND r.id=-1)) \n AND (\n (c.status='active' AND r.start_days IS NULL AND r.stop_days IS NULL AND r.start_payments = 0) \n OR\n (c.status='active' AND c.days BETWEEN IFNULL(r.start_days,0) AND IFNULL(r.stop_days, 90000) AND c.payments_count >= IFNULL(r.start_payments,0)) \n OR\n (c.days >= IFNULL(r.start_days,0) AND r.stop_days = -1 AND c.payments_count >= IFNULL(r.start_payments,0)) \n )");
// is available if free, or if user has equal subscription record in access_cache
$q->addWhere("(r.fn IN ('free', 'free_without_login') OR c.user_id IS NOT NULL)");
$q->addOrderRaw("(SELECT ras.sort_order\n FROM ?_resource_access_sort ras\n WHERE ras.resource_id=r.resource_id AND ras.resource_type=r.resource_type \n LIMIT 1), r.resource_id, r.resource_type");
return $q;
}