public function getItemsMenuData($pageNumber, $num, $key) { $goods = new DBGoodsType(); $navKeys = new DBNavKeyType(); $treeUtils = new TreeUtils(); $navKeys->executeRequest('', '', DB::TABLE_ORDER); $tree = $treeUtils->buildTreeByLeafs(); $keys = $treeUtils->getTreeLeafesForKey($tree, $key); $goods->getGoodsKeyCount($keys); $this->dataTotalCount = $goods->getTotalCount(); $limitBegin = ($pageNumber - 1) * $num; $limitEnd = $num; if ($this->isAdminOrderEnabled()) { $goods->getUserSortedForMenu($keys, $limitBegin, $limitEnd); } else { $str = implode('|', $keys); $goods->executeRequestRegExpWithLimit(DB::TABLE_NAV_KEY__KEY_ITEM, "^(" . $str . "){1}", DB::TABLE_GOODS___ORDER, DB::ASC, $limitBegin, $limitEnd); } $this->data = $goods->getResponse(); $this->dataCount = $goods->getResponseSize(); }
public static function getNextGoodCode($code) { $goodsType = new DBGoodsType(); $goodsType->executeRequestRegExpWithLimit(DB::TABLE_GOODS__KEY_ITEM, '^' . $code, DB::TABLE_GOODS__KEY_ITEM, DB::DESC, 0, 1); $nextCode = null; while ($row = mysql_fetch_array($goodsType->getResponse())) { $key_item = $row[DB::TABLE_GOODS__KEY_ITEM]; preg_match('/(\\d+)$/', $key_item, $matches); $numericPartOfCode = intval($matches[1]); ++$numericPartOfCode; $nextCode = $code . sprintf("%03d", $numericPartOfCode); break; } return $nextCode; }