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


PHP DbSimple_Generic类代码示例

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


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

示例1: __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

示例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: DbSimple_Mysql

 /**
  * constructor(string $dsn)
  * Connect to MySQL.
  */
 function DbSimple_Mysql($dsn)
 {
     $this->dsn = DbSimple_Generic::parseDSN($dsn);
     if (!is_callable('mysql_connect')) {
         return $this->_setLastError("-1", "MySQL extension is not loaded", "mysql_connect");
     }
 }
开发者ID:ru-easyfinance,项目名称:EasyFinance,代码行数:11,代码来源:Mysql.php

示例4: 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

示例5: ucfirst

 /**
  * DbSimple_Generic connect(mixed $dsn)
  * 
  * Universal static function to connect ANY database using DSN syntax.
  * Choose database driver according to DSN. Return new instance
  * of this driver.
  */
 function &connect($dsn)
 {
     // Load database driver and create its instance.
     $parsed = DbSimple_Generic::parseDSN($dsn);
     if (!$parsed) {
         $dummy = null;
         return $dummy;
     }
     $class = 'DbSimple_' . ucfirst($parsed['scheme']);
     if (!class_exists($class)) {
         $file = str_replace('_', '/', $class) . ".php";
         // Try to load library file from standard include_path.
         if ($f = @fopen($file, "r", true)) {
             fclose($f);
             require_once $file;
         } else {
             // Wrong include_path; try to load from current directory.
             $base = basename($file);
             $dir = dirname(__FILE__);
             if (@is_file($path = "{$dir}/{$base}")) {
                 require_once $path;
             } else {
                 trigger_error("Error loading database driver: no file {$file} in include_path; no file {$base} in {$dir}", E_USER_ERROR);
                 return null;
             }
         }
     }
     $object =& new $class($parsed);
     if (isset($parsed['ident_prefix'])) {
         $object->setIdentPrefix($parsed['ident_prefix']);
     }
     return $object;
 }
开发者ID:space77,项目名称:mwfv3_sp,代码行数:40,代码来源:Generic.php

示例6: __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

示例7: __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

示例8: __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

示例9: __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

示例10: 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

示例11: DbSimple_Mysql

 /**
  * constructor(string $dsn)
  * Connect to MySQL.
  */
 function DbSimple_Mysql($dsn)
 {
     $DbSimple_Generic = new DbSimple_Generic();
     // $p = DbSimple_Generic::parseDSN($dsn);
     $p = $DbSimple_Generic->parseDSN($dsn);
     if (!is_callable('mysql_connect')) {
         return $this->_setLastError("-1", "MySQL extension is not loaded", "mysql_connect");
     }
     $ok = $this->link = @mysql_connect($p['host'] . (empty($p['port']) ? "" : ":" . $p['port']), $p['user'], $p['pass'], true);
     $this->_resetLastError();
     if (!$ok) {
         return $this->_setDbError('mysql_connect()');
     }
     $ok = @mysql_select_db(preg_replace('{^/}s', '', $p['path']), $this->link);
     if (!$ok) {
         return $this->_setDbError('mysql_select_db()');
     }
 }
开发者ID:Romerohub,项目名称:RCMS,代码行数:22,代码来源:Mysql.php

示例12: __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

示例13: 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

示例14: DbSimple_Mysql

 /**
  * constructor(string $dsn)
  * Connect to MySQL.
  */
 function DbSimple_Mysql($dsn)
 {
     $DbSimple = new DbSimple_Generic();
     $p = $DbSimple->parseDSN($dsn);
     if (!is_callable('mysql_connect')) {
         return $this->_setLastError("-1", "MySQL extension is not loaded", "mysql_connect");
     }
     $ok = $this->link = @mysql_connect($str = $p['host'] . (empty($p['port']) ? "" : ":" . $p['port']), $p['user'], $p['pass'], true);
     $this->_resetLastError();
     if (!$ok) {
         return $this->_setDbError('mysql_connect("' . $str . '", "' . $p['user'] . '")');
     }
     $ok = @mysql_select_db(preg_replace('{^/}s', '', $p['path']), $this->link);
     if (!$ok) {
         return $this->_setDbError('mysql_select_db()');
     }
     if (isset($p["charset"])) {
         $this->query('SET NAMES ?', $p["charset"]);
     }
 }
开发者ID:Refuge89,项目名称:World-of-Warcraft-Trinity-Core-MaNGOS,代码行数:24,代码来源:Mysql.php

示例15: 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


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