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


PHP DbSimple_Generic::connect方法代码示例

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


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

示例1: __construct

 /**
  * Constructor 
  */
 private function __construct()
 {
     $connection = DbSimple_Generic::connect('mysqli://' . DB_USER . ':' . DB_PASS . '@' . DB_SERVER . '/' . DB_NAME);
     $connection->query("SET names utf8");
     $connection->setErrorHandler('dbErrorHandler');
     $connection->setLogger('dbLogger');
 }
开发者ID:gorvic,项目名称:L11,代码行数:10,代码来源:Database.php

示例2: __construct

 public function __construct()
 {
     global $g_config;
     // Подключаем модули для работы с DbSimple (не по подгрузится автолоудером)
     $path = dirname(__FILE__) . '/DbSimple/';
     require_once $path . 'Generic.php';
     require_once $path . 'Mysql.php';
     require_once $path . 'Postgresql.php';
     require_once $path . 'my/MyDataBaseLog.php';
     $dbs = $g_config['dbSimple']['databases'];
     // Собираем все объекты в $o
     $o = new stdClass();
     foreach ($dbs as $db => $conn) {
         $dsn = $conn['dsn'];
         $cacheFunc = isset($conn['pCacheFunc']) ? $conn['pCacheFunc'] : NULL;
         $o->{$db} = DbSimple_Generic::connect($dsn);
         if ($g_config['dbSimple']['logDbError']) {
             MyDataBaseLog::SetFuncOnError(array(__CLASS__, 'DbSimpleError'));
             $o->{$db}->setLogger(array('MyDataBaseLog', 'Log'));
             $o->{$db}->setErrorHandler(array('MyDataBaseLog', 'Error'));
         }
         if ($cacheFunc) {
             $o->{$db}->setCacher($cacheFunc);
         }
     }
     // Регистрируем все базы данных как объект $g_databases
     $GLOBALS['g_databases'] = $o;
 }
开发者ID:Volkodav-vvs,项目名称:Micron,代码行数:28,代码来源:Db.php

示例3: __construct

 public function __construct($config)
 {
     include_once "core/dbsimple/Generic.php";
     $this->rDB = DbSimple_Generic::connect($config['rdb']);
     $this->rDB->setErrorHandler("databaseErrorHandler");
     $this->rDB->query("SET NAMES ? ", $config['db_encoding']);
 }
开发者ID:Refuge89,项目名称:World-of-Warcraft-Trinity-Core-MaNGOS,代码行数:7,代码来源:class.account.php

示例4: __construct

 function __construct()
 {
     require_once "dbsimple/config.php";
     require_once "dbsimple/DbSimple/Generic.php";
     require_once "data_connection.php";
     $this->db = @DbSimple_Generic::connect('mysqli://' . $UserName . ':' . $Password . '@' . $ServerName . '/' . $Database);
 }
开发者ID:aic513,项目名称:Web-programming,代码行数:7,代码来源:connect_to_db.php

示例5: __construct

 function __construct($file = null)
 {
     global $db_config;
     include_once 'dbsimple/Generic.php';
     // including simple conecting for DB
     $this->DB = DbSimple_Generic::connect($db_config['dbc_dns']);
     $this->DB->setErrorHandler("databaseErrorHandler");
     // $this->DB->setLogger("databaseLogHandler");
     // $this->DB->setIdentPrefix($db_config['db_prefix']);
     $this->initDB();
     if ($file == null) {
         return;
     }
     if ($this->file = fopen(self::$_dir . $file, "rb")) {
         $ex = explode('.', $file);
         $this->name = $ex[0];
         $this->dom = new DOMDocument();
         $this->dom->preserveWhiteSpace = false;
         $this->dom->substituteEntities = true;
         $xmlfile = 'xml/' . $this->name . '.xml';
         if (file_exists($xmlfile)) {
             $this->dom->Load($xmlfile);
             $this->XML = $this->dom->getElementsByTagName('file')->item(0);
             $this->format = $this->XML->getAttribute('format');
             return;
         }
     } else {
         $this->error = sprintf($this->_STR['FILE_NOT_EXISTS'], $file);
     }
 }
开发者ID:Refuge89,项目名称:World-of-Warcraft-Trinity-Core-MaNGOS,代码行数:30,代码来源:dbc.class.php

示例6: db_connect

function db_connect($hostName, $userName, $dbPassword, $dbName)
{
    // Подключаемся к БД.
    $dbc = DbSimple_Generic::connect('mysqli://' . $userName . ':' . $dbPassword . '@' . $hostName . '/' . $dbName);
    $dbc->query('set names ?', 'utf8');
    return $dbc;
}
开发者ID:Ilnarnch,项目名称:lesson_10,代码行数:7,代码来源:functions.php

示例7: __construct

 /**
  * Initialize database & template handlers, sets up sql/site configs
  * @category Main system functions
  * @example Connector::__construct()
  * @return bool
  **/
 public function __construct()
 {
     include 'configuration.php';
     require_once 'libs/DbSimple/Generic.php';
     require_once 'libs/Smarty-2.6.26/Smarty.class.php';
     $this->mysqlconfig = $ArmoryConfig['mysql'];
     $this->armoryconfig = $ArmoryConfig['settings'];
     $this->aDB = DbSimple_Generic::connect('mysql://' . $this->mysqlconfig['user_armory'] . ':' . $this->mysqlconfig['pass_armory'] . '@' . $this->mysqlconfig['host_armory'] . '/' . $this->mysqlconfig['name_armory']);
     $this->cDB = DbSimple_Generic::connect('mysql://' . $this->mysqlconfig['user_characters'] . ':' . $this->mysqlconfig['pass_characters'] . '@' . $this->mysqlconfig['host_characters'] . '/' . $this->mysqlconfig['name_characters']);
     $this->rDB = DbSimple_Generic::connect('mysql://' . $this->mysqlconfig['user_realmd'] . ':' . $this->mysqlconfig['pass_realmd'] . '@' . $this->mysqlconfig['host_realmd'] . '/' . $this->mysqlconfig['name_realmd']);
     $this->wDB = DbSimple_Generic::connect('mysql://' . $this->mysqlconfig['user_mangos'] . ':' . $this->mysqlconfig['pass_mangos'] . '@' . $this->mysqlconfig['host_mangos'] . '/' . $this->mysqlconfig['name_mangos']);
     /*
     temporary disabled
     // Test connection
     if(!$this->aDB->selectCell("SELECT `id` FROM `classes` LIMIT 1")) {
         $this->databaseError('Can not execute query to armory database ("<i>%s</i>")!<br />Check you configuration.php for correct values.', $this->mysqlconfig['name_armory']);
     }
     if(!$this->cDB->selectCell("SELECT `guid` FROM `characters` LIMIT 1")) {
         $this->databaseError('Can not execute query to characters database ("<i>%s</i>")!<br />Check you configuration.php for correct values.', $this->mysqlconfig['name_characters']);
     }
     if(!$this->rDB->selectCell("SELECT `name` FROM `realmlist` LIMIT 1")) {
         $this->databaseError('Can not execute query to realmd database ("<i>%s</i>")!<br />Check you configuration.php for correct values.', $this->mysqlconfig['name_realmd']);
     }
     if(!$this->wDB->selectCell("SELECT `entry` FROM `item_template` LIMIT 1")) {
         $this->databaseError('Can not execute query to mangos database ("<i>%s</i>")!<br />Check you configuration.php for correct values.', $this->mysqlconfig['name_mangos']);
     }
     */
     $this->aDB->query("SET NAMES ?", $this->mysqlconfig['charset_armory']);
     $this->cDB->query("SET NAMES ?", $this->mysqlconfig['charset_characters']);
     $this->rDB->query("SET NAMES ?", $this->mysqlconfig['charset_realmd']);
     $this->wDB->query("SET NAMES ?", $this->mysqlconfig['charset_mangos']);
     $this->tpl = new Smarty();
     return true;
 }
开发者ID:ExTRaY,项目名称:wowarmory,代码行数:40,代码来源:class.connector.php

示例8: BDConnect

 function BDConnect()
 {
     $db = DbSimple_Generic::connect("mysqli://{$this->user}:{$this->pass}@{$this->host}/{$this->bd_name}");
     $db->query("SET NAMES utf8");
     $db->setErrorHandler('databaseErrorHandler');
     $db->setLogger('myLogger');
     return $db;
 }
开发者ID:BelousAlex,项目名称:Home-Work,代码行数:8,代码来源:HW11.php

示例9: connectDB

 public function connectDB()
 {
     // Подключаемся к БД.
     $db = DbSimple_Generic::connect("mysqli://{$this->db_user}:{$this->db_password}@{$this->db_host}/{$this->db_name}");
     $db->query("SET NAMES utf8");
     // Устанавливаем обработчик ошибок.
     $db->setErrorHandler('installErrorHandler');
     $db->setLogger('myLogger');
     return $db;
 }
开发者ID:Anatoliy-Bezhenaru,项目名称:wdc,代码行数:10,代码来源:install_class.php

示例10: __construct

 public function __construct($ini_file_name)
 {
     if (!($ini_array = $this->get_params_from_ini_file($ini_file_name))) {
         echo 'Отсутствует ' . $this->ini_file_name . ' файл. Перейдите к <a href="install.php">установке</a>';
         exit;
     }
     $this->db = DbSimple_Generic::connect('mysqli://' . $ini_array['UserName'] . ':' . $ini_array['Password'] . '@' . $ini_array['ServerName'] . '/' . $ini_array['Database']);
     $this->db->setErrorHandler('databaseErrorHandler');
     $this->db->setLogger('myLogger');
 }
开发者ID:slastenovd,项目名称:test2,代码行数:10,代码来源:AdsDBConnect.class.php

示例11: extract

function &connectMysql($conf)
{
    global $config;
    require_once $config['root_dir'] . '/includes/dbsimple/Generic.php';
    require_once $config['root_dir'] . '/includes/dbsimple/Mysql.php';
    extract($conf);
    $database =& DbSimple_Generic::connect(array('scheme' => 'mysql', 'user' => $user, 'pass' => $pass, 'host' => $host, 'path' => $db));
    $database->setErrorHandler('defaultDatabaseErrorHandler');
    $database->setIdentPrefix($prefix);
    return $database;
}
开发者ID:subashemphasize,项目名称:test_site,代码行数:11,代码来源:mysql.inc.php

示例12: GetConnect

 /**
  * Получает объект БД
  *
  * @param array $aConfig - конфиг подключения к БД(хост, логин, пароль, тип бд, имя бд)
  * @return DbSimple
  */
 public function GetConnect($aConfig = null)
 {
     /**
      * Если конфиг не передан то используем главный конфиг БД из config.php
      */
     if (is_null($aConfig)) {
         $aConfig = Config::Get('db.params');
     }
     $sDSN = $aConfig['type'] . 'wrapper://' . $aConfig['user'] . ':' . $aConfig['pass'] . '@' . $aConfig['host'] . ':' . $aConfig['port'] . '/' . $aConfig['dbname'];
     /**
      * Создаём хеш подключения, уникальный для каждого конфига
      */
     $sDSNKey = md5($sDSN);
     /**
      * Проверяем создавали ли уже коннект с такими параметрами подключения(DSN)
      */
     if (isset($this->aInstance[$sDSNKey])) {
         return $this->aInstance[$sDSNKey];
     } else {
         /**
          * Если такого коннекта еще не было то создаём его
          */
         $oDbSimple = DbSimple_Generic::connect($sDSN);
         /**
          * Устанавливаем хук на перехват ошибок при работе с БД
          */
         $oDbSimple->setErrorHandler('databaseErrorHandler');
         /**
          * Если нужно логировать все SQL запросы то подключаем логгер
          */
         if (Config::Get('sys.logs.sql_query')) {
             $oDbSimple->setLogger('databaseLogger');
         }
         /**
          * Устанавливаем настройки соединения, по хорошему этого здесь не должно быть :)
          * считайте это костылём
          */
         $oDbSimple->query("set character_set_client='utf8'");
         $oDbSimple->query("set character_set_results='utf8'");
         $oDbSimple->query("set collation_connection='utf8_bin'");
         /**
          * Сохраняем коннект
          */
         $this->aInstance[$sDSNKey] = $oDbSimple;
         /**
          * Возвращаем коннект
          */
         return $oDbSimple;
     }
 }
开发者ID:lifecom,项目名称:test,代码行数:56,代码来源:Database.class.php

示例13: _boot

 private function _boot()
 {
     session_start();
     ob_start();
     $this->_oConfig = new Config($this->_sConfigFile);
     setlocale(LC_ALL, $this->config->project->locale);
     require_once $_SERVER['DOCUMENT_ROOT'] . $this->config->db->lib_path . '/Generic.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . $this->config->db->lib_path . '/Mysql.php';
     $this->_oDb = \DbSimple_Generic::connect("mysql://" . $this->config->db->user . ($this->config->db->password ? ":" . $this->config->db->password : '') . "@" . $this->config->db->host . "/" . $this->config->db->database);
     $this->db->setIdentPrefix($this->config->db->table_prefix);
     $this->db->query("SET NAMES utf8");
     $oRoutesConfig = new Config($_SERVER['DOCUMENT_ROOT'] . $this->config->router->path);
     $this->_oRequest = new Request($oRoutesConfig->routes);
     $this->_oView = new View($this->config->templates->path, $this->_oRequest->lang);
     $this->_oDirector = new Director($this->options);
 }
开发者ID:s1im05,项目名称:tyampuru,代码行数:16,代码来源:application.class.php

示例14: __construct

 function __construct()
 {
     global $config;
     include_once dirname(__FILE__) . '/dbsimple/Generic.php';
     $this->cDB = DbSimple_Generic::connect($config['cdb']);
     $this->cDB->setErrorHandler("databaseErrorHandler");
     $this->cDB->query("SET NAMES ? ", $config['db_encoding']);
     $this->rDB = DbSimple_Generic::connect($config['rdb']);
     $this->rDB->setErrorHandler("databaseErrorHandler");
     $this->rDB->query("SET NAMES ? ", $config['db_encoding']);
     $this->wDB = DbSimple_Generic::connect($config['wdb']);
     $this->wDB->setErrorHandler("databaseErrorHandler");
     $this->wDB->query("SET NAMES ? ", $config['db_encoding']);
     if ($config['buildClient'] < 11723) {
         print "Некорректно настроен конфиг. Неизвесная сборка клиента (" . $config['buildClient'] . ")";
     }
 }
开发者ID:Refuge89,项目名称:World-of-Warcraft-Trinity-Core-MaNGOS,代码行数:17,代码来源:class.character.php

示例15: get

 /**
  * Возвращает экземпляр класса для подключения к бд
  *
  * @param string  $dbAlias
  * @return DbSimple_Generic
  */
 public static function get($dbAlias)
 {
     if (!isset(self::$_instances[$dbAlias])) {
         $db = DbSimple_Generic::connect(self::$_configs[$dbAlias]['connectUri']);
         if (self::$_configs[$dbAlias]['initSQL']) {
             $db->query(self::$_configs[$dbAlias]['initSQL']);
         }
         $db->setErrorHandler(array(__CLASS__, 'databaseErrorHandler'));
         $db->addIgnoreInTrace(__CLASS__ . '::databaseErrorHandler');
         if (self::$_configs[$dbAlias]['debug']) {
             $db->setLogger(array(__CLASS__, 'databaseLogger'));
             $db->addIgnoreInTrace(__CLASS__ . '::databaseLogger');
         }
         self::$_instances[$dbAlias] = $db;
     }
     return self::$_instances[$dbAlias];
 }
开发者ID:nagyistoce,项目名称:lanmediaservice-lms-lib,代码行数:23,代码来源:Db.php


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