本文整理汇总了PHP中xPDOQuery::having方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDOQuery::having方法的具体用法?PHP xPDOQuery::having怎么用?PHP xPDOQuery::having使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDOQuery
的用法示例。
在下文中一共展示了xPDOQuery::having方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addWhere
/**
* Adds where and having conditions
*/
public function addWhere()
{
$time = microtime(true);
$where = array();
if (!empty($this->config['where'])) {
$tmp = $this->config['where'];
if (is_string($tmp) && ($tmp[0] == '{' || $tmp[0] == '[')) {
$tmp = $this->modx->fromJSON($tmp);
}
if (!is_array($tmp)) {
$tmp = array($tmp);
}
$where = $this->replaceTVCondition($tmp);
}
$where = $this->additionalConditions($where);
if (!empty($where)) {
$this->query->where($where);
$condition = array();
foreach ($where as $k => $v) {
if (is_array($v)) {
if (isset($v[0])) {
$condition[] = is_array($v) ? $k . '(' . implode(',', $v) . ')' : $k . '=' . $v;
} else {
foreach ($v as $k2 => $v2) {
$condition[] = is_array($v2) ? $k2 . '(' . implode(',', $v2) . ')' : $k2 . '=' . $v2;
}
}
} else {
$condition[] = $k . '=' . $v;
}
}
$this->addTime('Added where condition: <b>' . implode(', ', $condition) . '</b>', microtime(true) - $time);
}
$time = microtime(true);
if (!empty($this->config['having'])) {
$tmp = $this->config['having'];
if (is_string($tmp) && ($tmp[0] == '{' || $tmp[0] == '[')) {
$tmp = $this->modx->fromJSON($tmp);
}
$having = $this->replaceTVCondition($tmp);
$this->query->having($having);
$condition = array();
foreach ($having as $k => $v) {
if (is_array($v)) {
$condition[] = $k . '(' . implode(',', $v) . ')';
} else {
$condition[] = $k . '=' . $v;
}
}
$this->addTime('Added having condition: <b>' . implode(', ', $condition) . '</b>', microtime(true) - $time);
}
}