/** * Returns corresponding instance of DBMS class. * * @return */ public static function getDBMS() { if (is_null(self::$dbmsInstance)) { self::$dbmsInstance = self::newClass(DBMS); } return self::$dbmsInstance; }
/** * Returns corresponding instance of DBMS class. * * @return */ public static function getDBMS() { if (is_null(self::$dbmsInstance)) { if (self::$IMPROVED) { ImprovedDBMS::init(self::$config); self::$dbmsInstance = ImprovedDBMS::getInstance(); } else { DBMS::init(self::$config); self::$dbmsInstance = DBMS::getInstance(); } } return self::$dbmsInstance; }
/** * <p>In the <b>_construct()</b> we are defining basic goals.</p> * <p><b>$package</b> is a folder name(for our custom case it is named "main") that we are create our class folder.</p> * <p><b>$command</b> is a defauld load name,that should be loaded at the first time,when you run it in you web browser.</p> * */ public function __construct() { //initilize db connection DBMSFactory::init(); //initilize load mapper if (defined("LOAD_MAPPER")) { $this->loadMapper = $this->newClass(LOAD_MAPPER); } if (defined("SESSION_MANAGER")) { $this->sessionManager = $this->newClass(SESSION_MANAGER); } $this->actionPackage = ACTIONS_DIR; $this->loadsPackage = LOADS_DIR; $command = ""; $args = array(); if (preg_match_all("/(\\/([^\\/]+))/", $_REQUEST["_url"], $matches)) { if ($matches[2][0] == "dynamic") { array_shift($matches[2]); $dynamicIndex = 9; //--/dynamic/ $loadArr = $this->loadMapper->getDynamicLoad(substr($_REQUEST["_url"], $dynamicIndex), $matches[2]); if (is_array($loadArr)) { $package = $loadArr["package"]; $command = $loadArr["command"]; $args = $loadArr["args"]; } else { $this->showNotFound(NoAccessException::$NOT_FOUND); return false; } } else { $package = array_shift($matches[2]); $command = array_shift($matches[2]); $args = $matches[2]; if (isset($args[count($args) - 1])) { if (preg_match("/(.+?)\\.ajax/", $args[count($args) - 1], $matches1)) { $this->isAjax = true; $args[count($args) - 1] = $matches1[1]; } } $package = str_replace("_", "/", $package); } } //--replacing separarators for getting real package's path //$this->sessionManager->setArgs($args); // $this->sessionManager->setDispatcher($this); $this->dispatch($package, $command, $args); }
<?php //ini_set('display_errors', true); //error_reporting(E_ALL); if (!$_SERVER["DOCUMENT_ROOT"]) { $_SERVER = array(); defined('__DIR__') or define('__DIR__', dirname(__FILE__)); $_SERVER["DOCUMENT_ROOT"] = __DIR__ . "/../.."; chdir($_SERVER["DOCUMENT_ROOT"]); } ini_set('memory_limit', '3G'); require_once $_SERVER["DOCUMENT_ROOT"] . "/conf/constants.php"; require_once CLASSES_PATH . "/framework/Dispatcher.class.php"; require_once CLASSES_PATH . "/loads/LoadMapper.class.php"; require_once CLASSES_PATH . "/util/db/DBMSFactory.class.php"; require_once CLASSES_PATH . "/managers/ItemManager.class.php"; $config = parse_ini_file(CONF_PATH . "/config.ini"); DBMSFactory::init($config); $itemManager = ItemManager::getInstance($config, null); $allItems = $itemManager->selectAll(); foreach ($allItems as $itemDto) { $itemForOrderDto = $itemManager->getItemWithCustomerPrice($itemDto->getId()); $customerItemPriceAmd = $itemManager->exchangeFromUsdToAMD($itemForOrderDto->getCustomerItemPrice()); $itemRandomDiscountPercent = rand(20, 28); $itemRandomDiscountParam = 1 - $itemRandomDiscountPercent / 100; $itemListPrice = intval($customerItemPriceAmd / $itemRandomDiscountParam); $itemDto->setListPriceAmd($itemListPrice); var_dump(intval((1 - $customerItemPriceAmd / $itemListPrice) * 100)); $itemManager->updateByPK($itemDto); }
/** * Initializes DB mappers * * @param object $config * @param object $args * @return */ function __construct($config, $args) { $this->config = $config; $this->args = $args; $this->dbms = DBMSFactory::getDBMS(); }
/** * Initializes DBMS pointer. */ function __construct() { $this->dbms = DBMSFactory::getDBMS(); }