Example #1
0
 /**
  * Connects to the DB, gets the data from DB
  * and creates an array of users which were stored in DB
  * @param nothing
  * @return  true, if the array containing users was created, false if an error appeared
  */
 public function generateArray()
 {
     try {
         $userArr = DB::getInstance()->getAllUsers();
         // Connect to DB and get users
         foreach ($userArr as $oneUser) {
             // For each row that represents one user
             $user = new User();
             $x = 0;
             // Counter
             foreach ($oneUser as $userData) {
                 // Set user data. Each cell in the row represents user's data
                 if ($x == 1) {
                     $user->setUsername($userData);
                 } elseif ($x == 2) {
                     $user->setPassword($userData);
                 }
                 $x++;
             }
             $this->add($user);
         }
         return true;
     } catch (Exception $e) {
         // Catch exception
         $this->errorMsg = $e->getMessage();
         // Get error message
         return false;
     }
 }
Example #2
0
 public static function run_json($sql)
 {
     $result = parent::getInstance()->getConnection()->query($sql);
     // reset json response
     JSON::$response = array();
     // If query failed, return `false`
     if ($result === FALSE) {
         JSON::$response[] = array("sql" => "nok");
         return;
     }
     if ($result === TRUE) {
         JSON::$response[] = array("sql" => "ok");
         return;
     }
     // reset json response
     JSON::$response = array();
     // If query was successful, retrieve all the rows into an array or True
     JSON::$response[] = array("sql" => "ok");
     $rows = array();
     while ($row = $result->fetch_assoc()) {
         // echoing JSON response
         JSON::$response[] = $row;
     }
     return;
 }
 /**
  * @brief Execute update
  **/
 function moduleUpdate()
 {
     $oDB =& DB::getInstance();
     $oModuleModel =& getModel('module');
     $oModuleController =& getController('module');
     return new Object(0, 'success_updated');
 }
Example #4
0
 /**
  * @brief 업데이트 실행
  **/
 function moduleUpdate()
 {
     $oModuleModel = getModel('module');
     $oModuleController = getController('module');
     $oDB = DB::getInstance();
     // 트리거 일괄 추가
     foreach ($this->add_triggers as $trigger) {
         if (!$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4])) {
             $oModuleController->insertTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]);
         }
     }
     if (!$oDB->isColumnExists('alliance_sites', 'title')) {
         $oDB->addColumn('alliance_sites', 'title', 'varchar', 250, '', true);
         $oDB->addIndex('alliance_sites', 'unique_title', 'title', true);
     }
     if (!$oDB->isColumnExists('alliance_logs', 'type')) {
         $oDB->addColumn('alliance_logs', 'type', 'char', 20, '', true);
     }
     if (!$oDB->isColumnExists('alliance_contents', 'site_srl')) {
         $oDB->addColumn('alliance_contents', 'site_srl', 'number', 11, 0, true);
         $oDB->addIndex('alliance_contents', 'idx_site_srl', 'site_srl');
     }
     if (!$oDB->isColumnExists('alliance_messages', 'title')) {
         $oDB->addColumn('alliance_messages', 'title', 'varchar', 250, '', true);
     }
     /* 2011.03.12 - 연합 정보 테이블의 count 칼럼 제거 */
     if ($oDB->isColumnExists('alliance_info', 'count')) {
         $oDB->dropColumn('alliance_info', 'count');
     }
     return new Object(0, 'success_updated');
 }
Example #5
0
 public function search($same, $keyword, $field)
 {
     $search = DB::getInstance()->query("SELECT * FROM suppliers WHERE {$same} = '{$keyword}'");
     foreach ($search->results() as $s) {
         return $s->{$field};
     }
 }
Example #6
0
 public static function count()
 {
     $sql = "SELECT count(*) as count FROM " . self::getTable();
     $query = DB::getInstance()->prepare($sql);
     $query->execute();
     return $query->fetch()['count'];
 }
 /**
  * Construct importer
  * @param string $fileName relative to FRONTEND_PATH
  */
 public function __construct($fileName)
 {
     $this->Reader = new BigFileReaderGZip($fileName);
     $this->DB = DB::getInstance();
     $this->AccountID = USER_MUST_LOGIN ? SessionAccountHandler::getId() : 0;
     $this->Results = new RunalyzeJsonImporterResults();
 }
Example #8
0
 public function __construct($page = null)
 {
     $this->_db = DB::getInstance();
     //set default home page
     $page = Input::get('page') ? Input::get('page') : Config::get('home');
     $this->find($page);
 }
Example #9
0
 /**
  * @brief Execute update
  **/
 function moduleUpdate()
 {
     $oModuleModel =& getModel('module');
     $oModuleController =& getController('module');
     $oDB =& DB::getInstance();
     // 2007. 10. 17 document.insertDocument, updateDocument, deleteDocument trigger property for
     if (!$oModuleModel->getTrigger('document.insertDocument', 'tag', 'controller', 'triggerArrangeTag', 'before')) {
         $oModuleController->insertTrigger('document.insertDocument', 'tag', 'controller', 'triggerArrangeTag', 'before');
     }
     if (!$oModuleModel->getTrigger('document.insertDocument', 'tag', 'controller', 'triggerInsertTag', 'after')) {
         $oModuleController->insertTrigger('document.insertDocument', 'tag', 'controller', 'triggerInsertTag', 'after');
     }
     if (!$oModuleModel->getTrigger('document.updateDocument', 'tag', 'controller', 'triggerArrangeTag', 'before')) {
         $oModuleController->insertTrigger('document.updateDocument', 'tag', 'controller', 'triggerArrangeTag', 'before');
     }
     if (!$oModuleModel->getTrigger('document.updateDocument', 'tag', 'controller', 'triggerInsertTag', 'after')) {
         $oModuleController->insertTrigger('document.updateDocument', 'tag', 'controller', 'triggerInsertTag', 'after');
     }
     if (!$oModuleModel->getTrigger('document.deleteDocument', 'tag', 'controller', 'triggerDeleteTag', 'after')) {
         $oModuleController->insertTrigger('document.deleteDocument', 'tag', 'controller', 'triggerDeleteTag', 'after');
     }
     // 2007. 10. 17 modules are deleted when you delete all registered triggers that add tag
     if (!$oModuleModel->getTrigger('module.deleteModule', 'tag', 'controller', 'triggerDeleteModuleTags', 'after')) {
         $oModuleController->insertTrigger('module.deleteModule', 'tag', 'controller', 'triggerDeleteModuleTags', 'after');
     }
     // tag in the index column of the table tag
     if (!$oDB->isIndexExists("tags", "idx_tag")) {
         $oDB->addIndex("tags", "idx_tag", array("document_srl", "tag"));
     }
     return new Object(0, 'success_updated');
 }
Example #10
0
 public function clear($user_id)
 {
     $sql = "delete FROM cart where user_id = {$user_id}";
     $db = DB::getInstance(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     $res = $db->query($sql);
     return true;
 }
Example #11
0
 public function Authenticate($Username = false, $Password = false, $Remember = false)
 {
     if ($Username !== false && $Password !== false) {
         //Confirm Input
         $UserData = DB::getInstance()->table("Users")->where("Username", $Username)->get(1)[0];
         $HashedPassAttempt = Hash::make(Input::get("Password"), $UserData->Salt);
         if ($HashedPassAttempt == $UserData->Password) {
             Session::put("UserID", $UserData->UserID);
             if ($Remember == 'on') {
                 //Was Remember Me Checkbox ticked?
                 $hashCheck = DB::getInstance()->table("user_sessions")->where('user_id', $UserData->UserID)->get();
                 //Check for existing session
                 if (count($hashCheck) == 0) {
                     //If there is not an existing hash
                     $hash = Hash::unique();
                     DB::getInstance()->table('user_sessions')->insert(array('user_id' => $UserData->UserID, 'hash' => $hash));
                 } else {
                     //use existing hash if found
                     $hash = $hashCheck[0]->hash;
                 }
                 $Cookie = Cookie::put(Config::get("remember/cookie_name"), $hash, Config::get("remember/cookie_expiry"));
                 //Set cookie
             }
             return $this->form($UserData->UserID);
             //Return User MetaTable
         } else {
             throw new Exception('Invalid Username or Password');
         }
     } else {
         throw new Exception('Invalid Username or Password');
     }
     return false;
 }
Example #12
0
    public static function saveProductCombinationSetting($id_product, $id_product_attribute, $display_button, $id_shop)
    {
        $id_giveit_product = DB::getInstance()->getValue('
			SELECT `id_giveit_product`
			FROM `' . _DB_PREFIX_ . self::$definition['table'] . '`
			WHERE `id_product` = "' . (int) $id_product . '"
				AND `id_product_attribute` = "' . (int) $id_product_attribute . '"
				AND `id_shop` = "' . (int) $id_shop . '"
		');
        if ($display_button == '') {
            return DB::getInstance()->Execute('
				DELETE FROM `' . _DB_PREFIX_ . self::$definition['table'] . '`
				WHERE `id_giveit_product` = "' . (int) $id_giveit_product . '"
			');
        }
        if ($id_giveit_product) {
            return DB::getInstance()->Execute('
				UPDATE `' . _DB_PREFIX_ . self::$definition['table'] . '`
				SET
					`display_button` = "' . (int) $display_button . '"
				WHERE `id_giveit_product` = "' . (int) $id_giveit_product . '"
			');
        }
        return DB::getInstance()->Execute('
			INSERT INTO `' . _DB_PREFIX_ . self::$definition['table'] . '`
				(`id_product`, `id_product_attribute`, `display_button`, `id_shop`, `date_add`, `date_upd`)
			VALUES
				("' . (int) $id_product . '", "' . (int) $id_product_attribute . '", "' . (int) $display_button . '", "' . (int) $id_shop . '", "' . date('Y-m-d H:i:s') . '", "' . date('Y-m-d H:i:s') . '")
		');
    }
 function GetChiefwhipByMunicipalityId($idMunicipality)
 {
     $sql = "SELECT DISTINCT\r\n\t\t\t\t\tanc_administrator.id_administrator AS 'id_chiefwhip',\r\n\t\t\t\t\tCONCAT(anc_administrator.first_name, ' ', anc_administrator.last_name) AS 'chiefwhip_name'\r\n\t\t\t\tFROM \r\n\t\t\t\t\tanc_administrator \r\n\t\t\t\tWHERE\r\n\t\t\t\t\tanc_administrator.id_municipality ='" . $idMunicipality . "' \r\n\t\t\t\tAND\r\n\t\t\t\t\tanc_administrator.id_administratortype='4' \r\n\t\t\t\tAND \r\n\t\t\t\t anc_administrator.administrator_status='1'";
     //echo $sql; exit;
     DB::getInstance()->query($querySuccess, $sql, $recordSet);
     return $recordSet;
 }
 /**
  * @brief 타임라인 게시판의 자식 게시판 등록
  * @param int $module_srl
  * @param array $target_srls
  * @return object
  */
 function insertAttachInfo($module_srl, $target_srls = array())
 {
     // 인자 유효성 검증
     if (!($module_srl && is_numeric($module_srl))) {
         return new Object(-1, 'msg_timeline_no_module_srl');
     }
     if (!is_array($target_srls)) {
         return new Object(-1, 'msg_invalid_request');
     }
     $oDB = DB::getInstance();
     $oDB->begin();
     // DB에 남아 있는 자식 게시판 정보 삭제
     $output = $this->deleteAttachInfo($module_srl);
     if (!$output->toBool()) {
         // DB 접근에 문제가 생겼을 경우 롤백
         $oDB->rollback();
         return $output;
     }
     $args = new stdClass();
     $args->module_srl = $module_srl;
     $args->priority = 0;
     // 배열로 입력 받은 target_srl 값을 하나씩 등록
     foreach ($target_srls as $target_srl) {
         $args->target_srl = $target_srl;
         $args->priority++;
         $output = executeQuery('timeline.insertAttachInfo', $args);
         if (!$output->toBool()) {
             // DB 접근에 문제가 생겼을 경우 롤백
             $oDB->rollback();
             return $output;
         }
     }
     $oDB->commit();
     return new Object();
 }
Example #15
0
 function Index()
 {
     echo '【DB类测试】<br />';
     $db = DB::getInstance();
     echo '1.查询 Cache 表 k 值为 plugins 的记录(单条)<br />记录信息:';
     dump($db->table('cache')->field(array('k', 'v'))->where(array('k' => 'plugins'))->find());
     echo '生成的SQL:' . $db->getLastSql() . '<br /><br />';
     echo '2.查询 sign_log 表的全部记录并统计签到经验(多条)<br />记录信息:';
     dump($db->table('sign_log')->field(array('SUM(exp)' => 'exp'))->group('uid')->select());
     echo '生成的SQL:' . $db->getLastSql() . '<br /><br />';
     echo '3.在 Cache 表插入一条记录<br />';
     $data = array('k' => 'test', 'v' => 'test');
     $flag = $db->table('cache')->insert($data);
     echo '生成的SQL:' . $db->getLastSql() . '<br />影响条数:' . intval($flag) . '<br /><br />';
     echo '4.在 Cache 表更新 k 值为 plugins 的记录<br />';
     $data['v'] = "testnow";
     $flag = $db->table('cache')->where(array('k' => 'test'))->update($data);
     echo '生成的SQL:' . $db->getLastSql() . '<br />影响条数:' . intval($flag) . '<br /><br />';
     echo '5.在 Cache 表删除 k 值为 plugins 的记录<br />';
     $flag = $db->table('cache')->where(array('k' => 'test'))->delete();
     echo '生成的SQL:' . $db->getLastSql() . '<br />影响条数:' . intval($flag) . '<br /><br />';
     echo '6.在 sign_log 表查询 uid 值为 4 且 date 值为 20140517 的签到记录<br />';
     dump($db->table(array('sign_log' => 'l'))->join(array('_table' => 'my_tieba', '_as' => 't', '_on' => 't.tid = l.tid', '_type' => 'LEFT JOIN'))->where(array('l.uid' => '4', 'l.date' => '20140517'))->order('l.uid DESC')->select());
     echo '生成的SQL:' . $db->getLastSql() . '<br />影响条数:' . intval($flag) . '<br /><br />';
     echo '用时' . (microtime(true) - START_TIME) * 1000 . '毫秒<br /><br />';
     echo '【GET测试】<br />GET值:';
     dump($_GET);
 }
 /**
  * @brief 카운터 기록
  **/
 function procCounterExecute()
 {
     $oDB =& DB::getInstance();
     $oDB->begin();
     $site_module_info = Context::get('site_module_info');
     $site_srl = (int) $site_module_info->site_srl;
     // 로그를 검사
     $oCounterModel =& getModel('counter');
     // 오늘자 row가 있는지 체크하여 없으면 등록
     if (!$oCounterModel->isInsertedTodayStatus($site_srl)) {
         $this->insertTodayStatus(0, $site_srl);
         // 기존 row가 있으면 사용자 체크
     } else {
         // 등록되어 있지 않은 아이피일 경우
         if (!$oCounterModel->isLogged($site_srl)) {
             // 로그 등록
             $this->insertLog($site_srl);
             // unique 및 pageview 등록
             $this->insertUniqueVisitor($site_srl);
         } else {
             // pageview 등록
             $this->insertPageView($site_srl);
         }
     }
     $oDB->commit();
 }
Example #17
0
 public function __construct()
 {
     /* Get all modules then select only payment ones*/
     $modules = Module::getModulesOnDisk();
     foreach ($modules as $module) {
         if ($module->tab == 'Payment') {
             if ($module->id) {
                 $module->country = array();
                 $countries = DB::getInstance()->ExecuteS('SELECT id_country FROM ' . _DB_PREFIX_ . 'module_country WHERE id_module = ' . intval($module->id));
                 foreach ($countries as $country) {
                     $module->country[] = $country['id_country'];
                 }
                 $module->currency = array();
                 $currencies = DB::getInstance()->ExecuteS('SELECT id_currency FROM ' . _DB_PREFIX_ . 'module_currency WHERE id_module = ' . intval($module->id));
                 foreach ($currencies as $currency) {
                     $module->currency[] = $currency['id_currency'];
                 }
                 $module->group = array();
                 $groups = DB::getInstance()->ExecuteS('SELECT id_group FROM ' . _DB_PREFIX_ . 'module_group WHERE id_module = ' . intval($module->id));
                 foreach ($groups as $group) {
                     $module->group[] = $group['id_group'];
                 }
             } else {
                 $module->country = NULL;
                 $module->currency = NULL;
                 $module->group = NULL;
             }
             $this->paymentModules[] = $module;
         }
     }
     parent::__construct();
 }
Example #18
0
 /**
  * Execute update
  *
  * @return Object
  */
 function moduleUpdate()
 {
     $oDB = DB::getInstance();
     if (!$oDB->isColumnExists("addons", "is_used_m")) {
         $oDB->addColumn("addons", "is_used_m", "char", 1, "N", TRUE);
     }
     if (!$oDB->isColumnExists("addons_site", "is_used_m")) {
         $oDB->addColumn("addons_site", "is_used_m", "char", 1, "N", TRUE);
     }
     // 2011. 7. 29. add is_fixed column
     if (!$oDB->isColumnExists('addons', 'is_fixed')) {
         $oDB->addColumn('addons', 'is_fixed', 'char', 1, 'N', TRUE);
         // move addon info to addon_site table
         $output = executeQueryArray('addon.getAddons');
         if ($output->data) {
             foreach ($output->data as $row) {
                 $args = new stdClass();
                 $args->site_srl = 0;
                 $args->addon = $row->addon;
                 $args->is_used = $row->is_used;
                 $args->is_used_m = $row->is_used_m;
                 $args->extra_vars = $row->extra_vars;
                 executeQuery('addon.insertSiteAddon', $args);
             }
         }
     }
     return new Object(0, 'success_updated');
 }
Example #19
0
 public function __construct($user = NULL)
 {
     //get db instance
     $this->_db = DB::getInstance();
     //get session name, which is just 'user'. See init.php
     $this->_sessionName = Config::get('session/session_name');
     $this->_cookieName = Config::get('remember/cookie_name');
     if (!$user) {
         //if a user has NOT been defined
         if (Session::exists($this->_sessionName)) {
             $user = Session::get($this->_sessionName);
             //check if user exists
             if ($this->find($user)) {
                 //if there is a session and the user exists,
                 //signify they're logged in
                 $this->_isLoggedIn = true;
             } else {
                 //process logout
             }
         }
     } else {
         //if a user HAS been defined
         $this->find($user);
     }
     //end if
 }
Example #20
0
 public function fetch()
 {
     $result = array();
     try {
         $stmt = DB::getInstance()->prepare("SELECT *\n\t\t\t\t\t\t\t\t\t\t\t\t\tFROM config\n\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(id = :config_id OR :config_id=0) AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(name = :name OR :name='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(value = :value OR :value='') AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(create_date = FROM_UNIXTIME(:create_date) OR :create_date=0) AND\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t(update_date = FROM_UNIXTIME(:update_date) OR :update_date=0)");
         $stmt->bindParam(':config_id', $this->getConfigId(), PDO::PARAM_INT);
         $stmt->bindParam(':name', $this->getName(), PDO::PARAM_STR);
         $stmt->bindParam(':value', $this->getValue(), PDO::PARAM_STR);
         $stmt->bindParam(':create_date', $this->getCreateDate(), PDO::PARAM_INT);
         $stmt->bindParam(':update_date', $this->getUpdateDate(), PDO::PARAM_INT);
         $stmt->execute();
         $result = $stmt->fetch(PDO::FETCH_ASSOC);
     } catch (PDOException $e) {
         echo $e->getMessage();
         echo $e->getTraceAsString();
     }
     if (!empty($result)) {
         $this->setConfigId((int) $result['id']);
         $this->setName($result['name']);
         $this->setValue($result['value']);
         $this->setCreateDate($result['create_date']);
         $this->setUpdateDate($result['update_date']);
         return true;
     }
     return false;
 }
Example #21
0
 private function _getDB($settings)
 {
     if (!defined('DB_HOST')) {
         define('DB_HOST', $settings['hostname']);
         // set database host
     }
     if (!defined('DB_USER')) {
         define('DB_USER', $settings['username']);
         // set database user
     }
     if (!defined('DB_PASS')) {
         define('DB_PASS', $settings['password']);
         // set database password
     }
     if (!defined('DB_NAME')) {
         define('DB_NAME', $settings['dbname']);
         // set database name
     }
     if (!defined('SEND_ERRORS_TO')) {
         define('SEND_ERRORS_TO', 'amit@khare.co.in');
         //set email notification email address
     }
     if (!defined('DISPLAY_DEBUG')) {
         define('DISPLAY_DEBUG', true);
         //display db errors?
     }
     $database = \DB::getInstance();
     return $database;
 }
Example #22
0
function buildAction($name = '')
{
    if (empty($name)) {
        $db = DB::getInstance();
        $tables = $db->getTables(DB_NAME);
        foreach ($tables as $table) {
            $table = str_replace(DB_PREFIX, '', $table);
            buildAction($table);
        }
    } else {
        $name = ucwords($name);
        echo '正在生成' . $name . 'Action类...';
        $filename = APP_PATH . 'Lib/Action/' . $name . 'Action.class.php';
        if (!file_exists($filename)) {
            $content = "<?php \n";
            $content .= "class " . $name . "Action extends Action \n{\n";
            $content .= "}\n?>";
            if (file_put_contents($filename, $content)) {
                echo "...Complete\n";
            } else {
                echo "...Fail\n";
            }
        } else {
            echo "...Exists\n";
        }
    }
}
Example #23
0
 /**
  * Counter logs
  *
  * @return void
  **/
 function counterExecute()
 {
     $oDB =& DB::getInstance();
     $oDB->begin();
     $site_module_info = Context::get('site_module_info');
     $site_srl = (int) $site_module_info->site_srl;
     // Check the logs
     $oCounterModel =& getModel('counter');
     // Register today's row if not exist
     if (!$oCounterModel->isInsertedTodayStatus($site_srl)) {
         $this->insertTodayStatus(0, $site_srl);
         // check user if the previous row exists
     } else {
         // If unregistered IP
         if (!$oCounterModel->isLogged($site_srl)) {
             // Leave logs
             $this->insertLog($site_srl);
             // Register unique and pageview
             $this->insertUniqueVisitor($site_srl);
         } else {
             //  Register pageview
             $this->insertPageView($site_srl);
         }
     }
     $oDB->commit();
 }
Example #24
0
function convert_product_price()
{
    $taxes = Db::getInstance()->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'tax');
    $taxRates = array();
    foreach ($taxes as $data) {
        $taxRates[$data['id_tax']] = (double) $data['rate'] / 100;
    }
    $resource = DB::getInstance()->executeS('SELECT `id_product`, `price`, `id_tax` 
		FROM `' . _DB_PREFIX_ . 'product`', false);
    if (!$resource) {
        return array('error' => 1, 'msg' => Db::getInstance()->getMsgError());
    }
    // was previously die(mysql_error())
    while ($row = DB::getInstance()->nextRow($resource)) {
        if ($row['id_tax']) {
            $price = $row['price'] * (1 + $taxRates[$row['id_tax']]);
            $decimalPart = $price - (int) $price;
            if ($decimalPart < 1.0E-6) {
                $newPrice = (double) number_format($price, 6, '.', '');
                $newPrice = Tools::floorf($newPrice / (1 + $taxRates[$row['id_tax']]), 6);
                DB::getInstance()->execute('UPDATE `' . _DB_PREFIX_ . 'product` SET `price` = ' . $newPrice . ' WHERE `id_product` = ' . (int) $row['id_product']);
            }
        }
    }
}
 function moduleUpdate()
 {
     $oModuleModel = getModel('module');
     $oModuleController = getController('module');
     $oDB =& DB::getInstance();
     foreach ($this->triggers as $trigger) {
         if (!$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4])) {
             $oModuleController->insertTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]);
         }
     }
     if (!$oDB->isColumnExists('androidpushapp_gcmregid', 'member_srl')) {
         $oDB->addColumn('androidpushapp_gcmregid', 'member_srl', 'number', 11);
     }
     if (!$oDB->isColumnExists('androidpushapp_gcmregid', 'setting')) {
         $oDB->addColumn('androidpushapp_gcmregid', 'setting', 'text');
     }
     if (!$oDB->isColumnExists('androidpushapp_gcmregid', 'setting_board')) {
         $oDB->addColumn('androidpushapp_gcmregid', 'setting_board', 'text');
     }
     if (!$oDB->isColumnExists('androidpushapp_gcmregid', 'last_login')) {
         $oDB->addColumn('androidpushapp_gcmregid', 'last_login', 'date');
     }
     if (!$oDB->isColumnExists('androidpushapp_gcmregid', 'sort')) {
         $oDB->addColumn('androidpushapp_gcmregid', 'sort', 'char', 1, 'W', 'true');
     }
     return new Object(0, 'success_updated');
 }
Example #26
0
 /**
  * @breif module update
  */
 function moduleUpdate()
 {
     $oModuleController =& getController('module');
     $oModuleModel =& getModel('module');
     $oDB =& DB::getInstance();
     if (!$oDB->isColumnExists('epay_transactions', 'target_module')) {
         $oDB->addColumn('epay_transactions', 'target_module', 'varchar', '80');
     }
     // 2012-04-06 regdate index added.
     if (!$oDB->isIndexExists('epay_transactions', 'idx_regdate')) {
         $oDB->addIndex('epay_transactions', 'idx_regdate', 'regdate');
     }
     // 2012-04-24 order_title column added.
     if (!$oDB->isColumnExists('epay_transactions', 'order_title')) {
         $oDB->addColumn('epay_transactions', 'order_title', 'varchar', '250');
     }
     // 2013-07-28 p_member_srl index added.
     if (!$oDB->isIndexExists('epay_transactions', 'idx_member_srl')) {
         $oDB->addIndex('epay_transactions', 'idx_member_srl', 'p_member_srl');
     }
     // added on 2015/06/13
     if (!$oModuleModel->getTrigger('cympusadmin.getManagerMenu', 'epay', 'model', 'triggerGetManagerMenu', 'before')) {
         $oModuleController->insertTrigger('cympusadmin.getManagerMenu', 'epay', 'model', 'triggerGetManagerMenu', 'before');
     }
     return new Object(0, 'success_updated');
 }
Example #27
0
 public static function getTopicName($topicid)
 {
     $query = "SELECT * FROM topics WHERE topicID=?";
     $param = array(0 => array($topicid, PDO::PARAM_STR));
     $res = DB::getInstance()->prepareAndExecuteQueryWithResult($query, $param);
     return $res;
 }
Example #28
0
 function read($session_key)
 {
     if (!$session_key || !$this->session_started) {
         return;
     }
     $oCacheHandler =& CacheHandler::getInstance('object');
     if ($oCacheHandler->isSupport()) {
         $cache_key = 'object:' . $session_key;
         $output->data = $oCacheHandler->get($cache_key);
     }
     if (!$output->data) {
         $args->session_key = $session_key;
         $columnList = array('session_key', 'cur_mid', 'val');
         $output = executeQuery('session.getSession', $args, $columnList);
         // Confirm there is a table created if read error occurs
         if (!$output->toBool()) {
             $oDB =& DB::getInstance();
             if (!$oDB->isTableExists('session')) {
                 $oDB->createTableByXmlFile($this->module_path . 'schemas/session.xml');
             }
             if (!$oDB->isColumnExists("session", "cur_mid")) {
                 $oDB->addColumn('session', "cur_mid", "varchar", 128);
             }
             $output = executeQuery('session.getSession', $args);
         }
         // Check if there is a table created in case there is no "cur_mid" value in the sessions information
         if (!isset($output->data->cur_mid)) {
             $oDB =& DB::getInstance();
             if (!$oDB->isColumnExists("session", "cur_mid")) {
                 $oDB->addColumn('session', "cur_mid", "varchar", 128);
             }
         }
     }
     return $output->data->val;
 }
Example #29
0
 public function __construct($user = null)
 {
     $this->_db = DB::getInstance();
     $this->_sessionName = Config::get('session/session_name');
     $this->_cookieName = Config::get('remember/cookie_name');
     $this->_admSessionName = Config::get('session/admin_name');
     if (!$user) {
         if (Session::exists($this->_sessionName)) {
             $user = Session::get($this->_sessionName);
             if ($this->find($user)) {
                 $this->_isLoggedIn = true;
             } else {
                 // process logout
             }
         }
         if (Session::exists($this->_admSessionName)) {
             $user = Session::get($this->_admSessionName);
             if ($this->find($user)) {
                 $this->_isAdmLoggedIn = true;
             } else {
                 // process logout
             }
         }
     } else {
         $this->find($user);
     }
 }
 /**
  * @brief 업데이트(업그레이드)
  **/
 function moduleUpdate()
 {
     $oDB =& DB::getInstance();
     $oModuleModel =& getModel('module');
     $oModuleController =& getController('module');
     if (!$oModuleModel->getTrigger('file.downloadFile', 'nstore_digital', 'controller', 'triggerCheckPermission', 'before')) {
         $oModuleController->insertTrigger('file.downloadFile', 'nstore_digital', 'controller', 'triggerCheckPermission', 'before');
     }
     if (!$oModuleModel->getTrigger('file.downloadFile', 'nstore_digital', 'controller', 'triggerUpdateDownloadedCount', 'after')) {
         $oModuleController->insertTrigger('file.downloadFile', 'nstore_digital', 'controller', 'triggerUpdateDownloadedCount', 'after');
     }
     if (!$oModuleModel->getTrigger('nproduct.getProcModules', 'nstore_digital', 'model', 'triggerGetProcModules', 'before')) {
         $oModuleController->insertTrigger('nproduct.getProcModules', 'nstore_digital', 'model', 'triggerGetProcModules', 'before');
     }
     if (!$oModuleModel->getTrigger('epay.processPayment', 'nstore_digital', 'controller', 'triggerProcessPayment', 'after')) {
         $oModuleController->insertTrigger('epay.processPayment', 'nstore_digital', 'controller', 'triggerProcessPayment', 'after');
     }
     if (!$oModuleModel->getTrigger('epay.processReview', 'nstore_digital', 'controller', 'triggerProcessReview', 'before')) {
         $oModuleController->insertTrigger('epay.processReview', 'nstore_digital', 'controller', 'triggerProcessReview', 'before');
     }
     if (!$oDB->isColumnExists('nstore_digital_cart', 'period')) {
         $oDB->addColumn('nstore_digital_cart', 'period', 'number', 11);
         $oDB->addIndex('nstore_digital_cart', 'idx_period', 'period');
     }
 }