本文整理汇总了PHP中ActiveRecordModel::getDBConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::getDBConnection方法的具体用法?PHP ActiveRecordModel::getDBConnection怎么用?PHP ActiveRecordModel::getDBConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecordModel
的用法示例。
在下文中一共展示了ActiveRecordModel::getDBConnection方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCountByPrices
public function getCountByPrices($includeAppliedFilters)
{
// get price filters
$k = 0;
$filters = array();
$config = $this->application->getConfig();
while ($config->isValueSet('PRICE_FILTER_NAME_' . ++$k)) {
if ($config->get('PRICE_FILTER_NAME_' . $k) && !is_array($config->get('PRICE_FILTER_NAME_' . $k))) {
$from = $config->get('PRICE_FILTER_FROM_' . $k);
$to = $config->get('PRICE_FILTER_TO_' . $k);
if ($to) {
$filters[$k] = array($from, $to);
}
}
}
if (!$filters) {
return array();
}
// get product counts
$selectFilter = $this->productFilter->getSelectFilter(!$includeAppliedFilters);
$selectFilter->removeFieldList();
$selectFilter->setLimit(0);
$query = new ARSelectQueryBuilder();
$query->includeTable('Product');
$query->joinTable('ProductPrice', 'Product', 'productID AND (ProductPrice.currencyID = "' . $this->application->getDefaultCurrencyCode() . '")', 'ID');
$query->joinTable('Category', 'Product', 'ID', 'categoryID');
foreach ($filters as $key => $filter) {
$query->addField('SUM(ProductPrice.price >= ' . $filter[0] . ' AND ProductPrice.price <= ' . $filter[1] . ')', null, $key);
}
$query->setFilter($selectFilter);
$data = ActiveRecordModel::getDataBySQL($query->getPreparedStatement(ActiveRecordModel::getDBConnection()));
//$data = array_diff($data[0], array(0));
return $data[0];
}
示例2: open
public function open()
{
try {
$this->db = ActiveRecordModel::getDBConnection();
$this->db->sessionHandler = $this;
return true;
} catch (SQLException $e) {
return false;
}
}