本文整理汇总了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']);
}
示例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;
}
示例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");
}
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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');
}
示例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;
}
示例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;
}
示例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()');
}
}
示例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');
}
示例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;
}
示例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"]);
}
}
示例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;
}