当前位置: 首页>>代码示例>>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;未经允许,请勿转载。