当前位置: 首页>>代码示例>>PHP>>正文


PHP DB::getInstance方法代码示例

本文整理汇总了PHP中DB::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getInstance方法的具体用法?PHP DB::getInstance怎么用?PHP DB::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB的用法示例。


在下文中一共展示了DB::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: generateArray

 /**
  * 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;
     }
 }
开发者ID:Janste,项目名称:Assignment_2_1DV608,代码行数:35,代码来源:UserArray.php

示例2: run_json

 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;
 }
开发者ID:divino-marchese,项目名称:android,代码行数:25,代码来源:Query.php

示例3: moduleUpdate

 /**
  * @brief Execute update
  **/
 function moduleUpdate()
 {
     $oDB =& DB::getInstance();
     $oModuleModel =& getModel('module');
     $oModuleController =& getController('module');
     return new Object(0, 'success_updated');
 }
开发者ID:seoeun,项目名称:xe-module-store_review,代码行数:10,代码来源:store_review.class.php

示例4: moduleUpdate

 /**
  * @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');
 }
开发者ID:haegyung,项目名称:alliancexe,代码行数:34,代码来源:alliance.class.php

示例5: search

 public function search($same, $keyword, $field)
 {
     $search = DB::getInstance()->query("SELECT * FROM suppliers WHERE {$same} = '{$keyword}'");
     foreach ($search->results() as $s) {
         return $s->{$field};
     }
 }
开发者ID:TSMS,项目名称:UCSC-groupProject-Tsms,代码行数:7,代码来源:Supplier.php

示例6: count

 public static function count()
 {
     $sql = "SELECT count(*) as count FROM " . self::getTable();
     $query = DB::getInstance()->prepare($sql);
     $query->execute();
     return $query->fetch()['count'];
 }
开发者ID:hugoboss62,项目名称:myMVC,代码行数:7,代码来源:ModelManager.php

示例7: __construct

 /**
  * 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();
 }
开发者ID:schoch,项目名称:Runalyze,代码行数:11,代码来源:class.RunalyzeJsonImporter.php

示例8: __construct

 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);
 }
开发者ID:NoOneLiv3,项目名称:TCS-Webstore,代码行数:7,代码来源:page.php

示例9: moduleUpdate

 /**
  * @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');
 }
开发者ID:relip,项目名称:xe-core,代码行数:34,代码来源:tag.class.php

示例10: clear

 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;
 }
开发者ID:Skynet2004x,项目名称:SkynetPR,代码行数:7,代码来源:cart.class.php

示例11: Authenticate

 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;
 }
开发者ID:25564,项目名称:Resume,代码行数:33,代码来源:User.php

示例12: saveProductCombinationSetting

    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') . '")
		');
    }
开发者ID:ventsiwad,项目名称:presta_addons,代码行数:30,代码来源:Product.php

示例13: GetChiefwhipByMunicipalityId

 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;
 }
开发者ID:ndumisom,项目名称:ANYC-Project,代码行数:7,代码来源:ajax.data.admin.class.php

示例14: insertAttachInfo

 /**
  * @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();
 }
开发者ID:ajkj,项目名称:xe-module-timeline,代码行数:41,代码来源:timeline.controller.php

示例15: Index

 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);
 }
开发者ID:JerryLocke,项目名称:Lite,代码行数:28,代码来源:Index.ctl.php


注:本文中的DB::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。