當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JO_Db::factory方法代碼示例

本文整理匯總了PHP中JO_Db::factory方法的典型用法代碼示例。如果您正苦於以下問題:PHP JO_Db::factory方法的具體用法?PHP JO_Db::factory怎麽用?PHP JO_Db::factory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在JO_Db的用法示例。


在下文中一共展示了JO_Db::factory方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createConnection

 /**
  * Create an instance of JO_Db_Adapter_Abstract.
  *
  * @param array $server master (supplier) or slave (consumer)
  * @return JO_Db_Adapter_Abstract|false
  * @see JO_Db
  */
 public function createConnection($server)
 {
     $config = $this->getConfig();
     foreach ($config as $key => $value) {
         if ('servers' !== $key && !array_key_exists($key, $server)) {
             $server[$key] = $value;
         }
     }
     $db = JO_Db::factory($config['adapter'], $server);
     if ($this->isConnected($db)) {
         return $db;
     }
     return false;
 }
開發者ID:NareshChennuri,項目名稱:pyng,代碼行數:21,代碼來源:DataSource.php

示例2: indexAction

 public function indexAction()
 {
     $request = $this->getRequest();
     $this->view->msg_error = array();
     $this->view->msg_success = array();
     //begin updater
     $sys_config = APPLICATION_PATH . '/config/config_db.ini';
     if (!file_exists($sys_config)) {
         $this->view->msg_error['old_sys'] = 'System Db config file not found: <strong>' . $sys_config . '</strong>';
     } elseif (!is_writable($sys_config)) {
         $this->view->msg_error['old_sys'] = '<strong>' . $sys_config . '</strong> must be writable!';
     }
     $upload_folder = BASE_PATH . '/uploads/';
     if (!is_writable($upload_folder)) {
         $this->view->msg_error['upload'] = '<strong>' . $upload_folder . '</strong> must be writable!';
     }
     $upload_folder = BASE_PATH . '/cache/';
     if (!is_writable($upload_folder)) {
         $this->view->msg_error['cache'] = '<strong>' . $upload_folder . '</strong> must be writable!';
     }
     if (!$this->view->msg_error && $request->getPost('install') == 'yes') {
         $db_params = $request->getPost('params');
         $db_params['charset'] = 'utf8';
         foreach ($db_params as $key => $value) {
             if (!$value && in_array($key, array('password', 'dbname'))) {
                 $db_params[$key] = ' ';
             }
         }
         $error = false;
         try {
             $db = JO_Db::factory("MYSQLi", $db_params);
             $db->query("ALTER DATABASE `" . $request->getPost('params[dbname]') . "` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci");
             $db->query("SET NAMES 'utf8'");
         } catch (JO_Db_Exception $e) {
             $error = $e->getMessage();
         }
         if ($db->isConnected()) {
             if (trim($request->getPost('username')) == '') {
                 $this->view->msg_error['username'] = 'You must type your username';
             } elseif (!preg_match('/^[a-zA-Z0-9_]+$/i', $request->getPost('username'))) {
                 $this->view->msg_error['username'] = 'The username you have entered is not valid';
             }
             if (trim($request->getPost('password')) == '') {
                 $this->view->msg_error['password'] = 'You must type your password';
             }
             if (trim($request->getPost('admin_mail')) == '') {
                 $this->view->msg_error['admin_mail'] = 'You must type your email';
             } elseif (!self::ValidMail($request->getPost('admin_mail'))) {
                 $this->view->msg_error['admin_mail'] = 'You must type valid email';
             }
             if (trim($request->getPost('report_mail')) == '') {
                 $this->view->msg_error['report_mail'] = 'You must type your email';
             } elseif (!self::ValidMail($request->getPost('report_mail'))) {
                 $this->view->msg_error['report_mail'] = 'You must type valid email';
             }
             if (count($this->view->msg_error) == 0) {
                 if ($request->getPost('demo') == 'yes') {
                     $result = Model_Install::installWithDemo($db);
                 } else {
                     $result = Model_Install::installWithoutDemo($db);
                 }
                 if ($result) {
                     JO_Action::getInstance()->redirect($request->getBaseUrl() . '?module=install&action=success');
                 } else {
                     $this->view->msg_error['install_error'] = 'An error occurred during installation. Try again to install and the installation fails, contact <a target="_blank" title="marketplace script" href="http://cloneforest.com"> Marketplace script </a>';
                 }
             }
         } else {
             $this->view->msg_error['db_connect'] = $error;
         }
     }
 }
開發者ID:noikiy,項目名稱:PD,代碼行數:72,代碼來源:IndexController.php

示例3: setDb

 /**
  * Set Db configuration settings
  *
  * @param  array $options
  * @return JO_Db
  */
 public function setDb($options)
 {
     $adapter = null;
     if (!isset($options['adapter'])) {
         throw new JO_Exception("Db adapter not set");
     } elseif (empty($options['adapter'])) {
         throw new JO_Exception("Db adapter is empty");
     }
     if (!isset($options['params']) || !is_array($options['params'])) {
         throw new JO_Exception("Db params error");
     }
     $this->_db = JO_Db_Table::setDefaultAdapter(JO_Db::factory($options['adapter'], $options['params']));
     return $this->_db;
 }
開發者ID:noikiy,項目名稱:amatteur,代碼行數:20,代碼來源:Application.php


注:本文中的JO_Db::factory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。