本文整理汇总了PHP中ActiveRecordModel::getRecordCount方法的典型用法代码示例。如果您正苦于以下问题:PHP ActiveRecordModel::getRecordCount方法的具体用法?PHP ActiveRecordModel::getRecordCount怎么用?PHP ActiveRecordModel::getRecordCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ActiveRecordModel
的用法示例。
在下文中一共展示了ActiveRecordModel::getRecordCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActiveProductManufacturers
/**
*
* @return array('manufacturers'=> array of manufacturers, 'counts'=> manufacturer product count, 'count'=> count of manufacturers)
*/
public static function getActiveProductManufacturers($context)
{
$context = $context + array('startingWith' => null, 'currentPage' => 1);
extract($context);
// creates $startingWith and $currentPage
$config = ActiveRecordModel::getApplication()->getConfig();
$listStyle = $config->get('MANUFACTURER_PAGE_LIST_STYLE');
$perPage = $config->get('MANUFACTURER_PAGE_PER_PAGE');
// get filter to select manufacturers of active products only
$f = new ARSelectFilter();
$ids = $counts = $letters = array();
$sql = !self::getApplication()->getConfig()->get('MANUFACTURER_PAGE_DISPLAY_ACTIVE') ? 'SELECT DISTINCT(ID) as manufacturerID, 1 AS cnt FROM Manufacturer ' . $f->createString() . ' GROUP BY manufacturerID' : 'SELECT DISTINCT(manufacturerID), COUNT(*) AS cnt FROM Product ' . $f->createString() . ' GROUP BY manufacturerID';
foreach (ActiveRecordModel::getDataBySQL($sql) as $row) {
$ids[] = $row['manufacturerID'];
$counts[$row['manufacturerID']] = $row['cnt'];
}
$f = new ARSelectFilter(new InCond(new ARFieldHandle('Manufacturer', 'ID'), $ids));
$f->addField('UPPER(LEFT(TRIM(Manufacturer.name),1))', '', 'FirstLetter');
$f->mergeCondition(new NotEqualsCond(new ARFieldHandle('Manufacturer', 'name'), ''));
if ($startingWith) {
$f->mergeCondition(new LikeCond(new ARFieldHandle('Manufacturer', 'name'), $startingWith . '%'));
}
$f->setOrder(new ARFieldHandle('Manufacturer', 'name'));
if ($perPage > 0) {
$offsetStart = ($currentPage - 1) * $perPage + 1;
$offsetEnd = $currentPage * $perPage;
$f->setLimit($perPage, $offsetStart - 1);
}
$manufacturers = ActiveRecordModel::getRecordSetArray(__CLASS__, $f);
foreach ($manufacturers as $item) {
$letters[$item['FirstLetter']] = $item['FirstLetter'];
}
return array('manufacturers' => $manufacturers, 'counts' => $counts, 'count' => ActiveRecordModel::getRecordCount(__CLASS__, $f));
}
示例2: getRecordCount
public static function getRecordCount($locale = null)
{
$filter = new ARSelectFilter();
if ($locale) {
$filter->mergeCondition(eq(f(__CLASS__ . '.locale'), $locale));
}
return ActiveRecordModel::getRecordCount(__CLASS__, $filter);
}
示例3: isValid
public function isValid($value)
{
ClassLoader::import('application.model.user.User');
$filter = new ARSelectFilter();
$cond = new EqualsCond(new ARFieldHandle('User', 'email'), $value);
$filter->setCondition($cond);
return ActiveRecordModel::getRecordCount('User', $filter) == 0;
}
示例4: fetchData
private function fetchData(SearchableModel $searchable, ARSelectFilter $filter)
{
$class = $searchable->getClassName();
$ret = array();
$ret['records'] = ActiveRecordModel::getRecordSetArray($class, $filter);
$ret['count'] = ActiveRecordModel::getRecordCount($class, $filter);
$ret['meta'] = $searchable->toArray();
return $ret;
}
示例5: insert
protected function insert()
{
$f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('SearchLog', 'keywords'), $this->keywords->get()));
$f->mergeCondition(new EqualsCond(new ARFieldHandle('SearchLog', 'ip'), $this->ip->get()));
if (!ActiveRecordModel::getRecordCount(__CLASS__, $f)) {
parent::insert();
$update = new ARUpdateFilter();
$update->addModifier('time', new ARExpressionHandle('NOW()'));
$update->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, 'ID'), $this->getID()));
ActiveRecordModel::updateRecordSet(__CLASS__, $update);
}
}
示例6: export
public function export()
{
@set_time_limit(0);
$count = ActiveRecordModel::getRecordCount($this->getClassName(), $this->getListFilter(), $this->getReferencedData());
$bufferCnt = ceil($count / self::EXPORT_BUFFER_ROW_COUNT);
// init file download
header('Content-Disposition: attachment; filename="' . $this->getCSVFileName() . '"');
header('Content-Type: text/csv');
$out = fopen('php://output', 'w');
// header row
$columns = $this->getExportColumns();
unset($columns['hiddenType']);
fputcsv($out, $columns);
// data
for ($bufferIndex = 1; $bufferIndex <= $bufferCnt; $bufferIndex++) {
foreach ($this->lists(true, $columns, $bufferIndex) as $row) {
fputcsv($out, $row);
}
}
exit;
}
示例7: fetchData
private function fetchData(SearchableModel $searchable, ARSelectFilter $filter)
{
$class = $searchable->getClassName();
$ret = array();
$ret['records'] = ActiveRecordModel::getRecordSetArray($class, $filter, true);
$ret['count'] = ActiveRecordModel::getRecordCount($class, $filter);
// calculate form and to
$ret['from'] = $filter->getOffset();
$ret['to'] = $filter->getLimit() + $ret['from'];
$diff = $ret['to'] - $ret['from'];
$c = count($ret['records']);
if ($diff != $c) {
$ret['to'] = $ret['from'] + $c;
}
$ret['from']++;
$ret['meta'] = $searchable->toArray();
if (method_exists($this, 'toArray_' . $searchable->getClassName())) {
call_user_func_array(array($this, 'toArray_' . $searchable->getClassName()), array(&$ret['records']));
}
return $ret;
}
示例8: countInvoices
public function countInvoices($filter = null)
{
$filter = $filter ? $filter : new ARSelectFilter();
$filter->mergeCondition(new AndChainCondition(array(new EqualsCond(new ARFieldHandle('CustomerOrder', 'userID'), $this->getID()), new EqualsCond(new ARFieldHandle('CustomerOrder', 'isRecurring'), 1), new IsNotNullCond(new ARFieldHandle('CustomerOrder', 'parentID')))));
return ActiveRecordModel::getRecordCount('CustomerOrder', $filter);
}
示例9: getTabCounts
private function getTabCounts($categoryId)
{
ClassLoader::import('application.model.category.*');
ClassLoader::import('application.model.filter.*');
ClassLoader::import('application.model.product.*');
$category = Category::getInstanceByID($categoryId, Category::LOAD_DATA);
$reviewCond = new EqualsOrMoreCond(new ARFieldHandle('Category', 'lft'), $category->lft->get());
$reviewCond->addAND(new EqualsOrLessCond(new ARFieldHandle('Category', 'rgt'), $category->rgt->get()));
return array('tabProducts' => $category->totalProductCount->get(), 'tabFilters' => $this->getFilterCount($category), 'tabFields' => $this->getSpecFieldCount($category), 'tabImages' => $this->getCategoryImageCount($category), 'tabOptions' => $category->getOptions()->getTotalRecordCount(), 'tabRatingCategories' => ProductRatingType::getCategoryRatingTypes($category)->size(), 'tabReviews' => ActiveRecordModel::getRecordCount('ProductReview', new ARSelectFilter($reviewCond), array('Category', 'Product')), 'tabProductLists' => $category->getRelatedRecordCount('ProductList'));
}
示例10: getOrderCount
protected function getOrderCount($from, $to)
{
$cond = new EqualsOrMoreCond(new ARFieldHandle('CustomerOrder', 'dateCompleted'), getDateFromString($from));
if ('now' != $to) {
$cond->addAnd(new EqualsOrLessCond(new ARFieldHandle('CustomerOrder', 'dateCompleted'), getDateFromString($to)));
}
$f = new ARSelectFilter($cond);
$f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), true));
$f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isCancelled'), false));
return ActiveRecordModel::getRecordCount('CustomerOrder', $f);
}
示例11: hasRecurringOrder
public static function hasRecurringOrder()
{
ClassLoader::import('application.model.product.RecurringItem');
ClassLoader::import('application.model.product.RecurringProductPeriod');
$filter = new ARSelectFilter();
$filter->setCondition(new EqualsCond(new ARFieldHandle(__CLASS__, 'isRecurring'), 1));
return (bool) ActiveRecordModel::getRecordCount(__CLASS__, $filter);
}
示例12: saveState
public function saveState(State $state)
{
// make sure that such state doesn't exist already
$f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('State', 'countryID'), $state->countryID->get()));
$f->mergeCondition(new EqualsCond(new ARFieldHandle('State', 'code'), $state->code->get()));
if (!ActiveRecordModel::getRecordCount('State', $f)) {
return $state->save();
}
}
示例13: isCouponCodes
public static function isCouponCodes()
{
$c = new NotEqualsCond(new ARFieldHandle(__CLASS__, 'couponCode'), '');
$c->addAND(new EqualsCond(new ARFieldHandle(__CLASS__, 'isEnabled'), 1));
return ActiveRecordModel::getRecordCount(__CLASS__, new ARSelectFilter($c));
}
示例14: removeUnchangedDataFromSnapshot
public function removeUnchangedDataFromSnapshot($timestamp)
{
if (!$timestamp) {
return;
}
// changes in category selection, needs full update
if (ActiveRecordModel::getRecordCount('ClonedStoreCategory', select(gte(f('ClonedStoreCategory.lastModifiedTime'), $timestamp)))) {
return;
}
ActiveRecordModel::executeUpdate('SET FOREIGN_KEY_CHECKS=0');
foreach ($this->tables as $table) {
ActiveRecordModel::executeUpdate('DELETE FROM ' . $this->importDatabase . '.' . $table . ' WHERE lastModifiedTime<"' . $timestamp . '"');
}
ActiveRecordModel::executeUpdate('SET FOREIGN_KEY_CHECKS=1');
}
示例15: isPurchaseRequiredToRate
private function isPurchaseRequiredToRate(Product $product)
{
if ($this->config->get('REQUIRE_PURCHASE_TO_RATE')) {
if ($this->user->isAnonymous()) {
return true;
}
if (is_null($this->isPurchaseRequiredToRate)) {
ClassLoader::import('application.model.order.CustomerOrder');
$f = new ARSelectFilter(new EqualsCond(new ARFieldHandle('CustomerOrder', 'userID'), $this->user->getID()));
$f->mergeCondition(new EqualsCond(new ARFieldHandle('OrderedItem', 'productID'), $product->getID()));
$f->mergeCondition(new EqualsCond(new ARFieldHandle('CustomerOrder', 'isFinalized'), 1));
$f->setLimit(1);
$this->isPurchaseRequiredToRate = ActiveRecordModel::getRecordCount('OrderedItem', $f, array('CustomerOrder')) < 1;
}
return $this->isPurchaseRequiredToRate;
}
}