本文整理汇总了PHP中Zend_Db_Table_Select::having方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Db_Table_Select::having方法的具体用法?PHP Zend_Db_Table_Select::having怎么用?PHP Zend_Db_Table_Select::having使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Db_Table_Select
的用法示例。
在下文中一共展示了Zend_Db_Table_Select::having方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _applySelectOptions
protected function _applySelectOptions(Zend_Db_Table_Select $select, array $options = array())
{
if (isset($options[self::OPTION_WHERE])) {
foreach ((array) $options[self::OPTION_WHERE] as $where) {
$select->where($where);
}
}
if (isset($options[self::OPTION_OR_WHERE])) {
foreach ((array) $options[self::OPTION_OR_WHERE] as $orWhere) {
$select->orWhere($orWhere);
}
}
if (isset($options[self::OPTION_HAVING])) {
foreach ((array) $options[self::OPTION_HAVING] as $having) {
$select->having($having);
}
}
if (isset($options[self::OPTION_ORDER])) {
foreach ((array) $options[self::OPTION_ORDER] as $order) {
$select->order($order);
}
}
$limit = isset($options[self::OPTION_LIMIT]) ? $options[self::OPTION_LIMIT] : null;
$offset = isset($options[self::OPTION_OFFSET]) ? $options[self::OPTION_OFFSET] : null;
$select->limit($limit, $offset);
return $select;
}
示例2: direct
/**
* Get DataTable data
*
* @param Zend_Db_Table_Select $select
* @param array|null $columns
* @return array
*/
public function direct(Zend_Db_Table_Select $select, $columns = null)
{
$table = $select->getTable();
if (!$columns) {
$columns = $table->info(Zend_Db_Table_Abstract::COLS);
}
$colCount = count($columns);
$request = $this->getRequest();
/*
* Ordering
*/
if (null !== $request->getParam('iSortCol_0', null)) {
for ($i = 0, $l = $request->getParam('iSortingCols'); $i < $l; $i++) {
if ($request->getParam('bSortable_' . (int) $request->getParam('iSortCol_' . $i))) {
$select->order($columns[(int) $request->getParam('iSortCol_' . $i)] . " " . $request->getParam('sSortDir_' . $i));
}
}
}
/*
* Filtering
* NOTE this does not match the built-in DataTables filtering which does it
* word by word on any field. It's possible to do here, but concerned about efficiency
* on very large tables, and MySQL's regex functionality is very limited
*/
if ($search = $request->getParam('sSearch')) {
for ($i = 0; $i < $colCount; $i++) {
$select->orHaving("{$columns[$i]} LIKE ?", '%' . $search . '%');
}
}
/* Individual column filtering */
for ($i = 0; $i < $colCount; $i++) {
if ($request->getParam('bSearchable_' . $i) == "true") {
if ($search = $request->getParam('sSearch_' . $i)) {
$select->having("{$columns[$i]} LIKE ?", '%' . $search . '%');
}
}
}
//save current query for fetching data
$query = clone $select;
$tableName = $table->info(Zend_Db_Table::NAME);
$expr = new Zend_Db_Expr('COUNT(*) as total');
/* Data set length after filtering */
if ($select->getPart(Zend_Db_Select::FROM)) {
$select->columns($expr);
} else {
$select->from($tableName, $expr);
}
/* Data no result */
if ($iFilteredTotal = $table->fetchRow($select)) {
$iFilteredTotal = $iFilteredTotal->total;
} else {
$iFilteredTotal = 0;
}
$query->limit($request->getParam('iDisplayLength'), $request->getParam('iDisplayStart'));
/*
* SQL queries
* Get data to display
*/
if ($query->getPart(Zend_Db_Select::FROM)) {
$query->columns($columns);
} else {
$query->from($tableName, $columns);
}
// Get total rows count
$select = $table->select()->from($tableName, $expr);
$iTotalRecords = $table->fetchRow($select)->total;
return array("sEcho" => (int) $request->getParam('sEcho'), "aaData" => $table->fetchAll($query)->toArray(), "iTotalRecords" => $iTotalRecords, "iTotalDisplayRecords" => $iFilteredTotal);
}