本文整理匯總了PHP中parent::db方法的典型用法代碼示例。如果您正苦於以下問題:PHP parent::db方法的具體用法?PHP parent::db怎麽用?PHP parent::db使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類parent
的用法示例。
在下文中一共展示了parent::db方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: singleton
/**
* Create a singleton of ADODB or ADODBLite; This driver works for
* both. Just specify the correct directory in
* config->db->options->adodbDir.
* The directory in which adodbDir resides in must be in your
* include_path.
*
* @access public
* @throws Framework_DB_Exception on failure
* @return object Instance of ADODB[Lite] connected to the DB
*/
public function singleton()
{
if (!is_null(parent::$db) && parent::$db instanceof ADOConnection) {
return parent::$db;
}
// Manually include files, ADODB does not follow naming conventions
if (empty($this->options->adodbDir)) {
throw new Framework_DB_Exception('Error: you must set $config->db->options->adodbDir');
}
$path = (string) $this->options->adodbDir . DIRECTORY_SEPARATOR;
if (!(include_once $path . 'adodb-exceptions.inc.php') || !(include_once $path . 'adodb.inc.php')) {
throw new Framework_DB_Exception('Error: could not include ADODB files');
}
// Connect
try {
parent::$db = ADONewConnection($this->dsn);
} catch (Exception $error) {
throw new Framework_DB_Exception($error->getMessage(), $error->getCode());
}
// Fetch Modes
$fetchModes = array('ADODB_FETCH_DEFAULT' => ADODB_FETCH_DEFAULT, 'ADODB_FETCH_NUM' => ADODB_FETCH_NUM, 'ADODB_FETCH_ASSOC' => ADODB_FETCH_ASSOC, 'ADODB_FETCH_BOTH' => ADODB_FETCH_BOTH);
$fetchMode = ADODB_FETCH_ASSOC;
if (isset($this->options->fetchMode) && isset($fetchModes[(string) $this->options->fetchMode])) {
$fetchMode = $fetchModes[(string) $this->options->fetchMode];
}
parent::$db->SetFetchMode($fetchMode);
return parent::$db;
}
示例2: singleton
/**
* Create a singleton of PEAR's DB
*
* @access public
* @return object Instance of PEAR DB connected to the DB
* @throws Framework_DB_Exception
*/
public function singleton()
{
if (!is_null(parent::$db) && parent::$db instanceof MDB2_Driver_Common) {
return parent::$db;
}
parent::$db = MDB2::connect($this->dsn);
if (PEAR::isError(parent::$db)) {
throw new Framework_DB_Exception(parent::$db->getMessage(), parent::$db->getCode());
}
$fetchMode = MDB2_FETCHMODE_ASSOC;
if (isset($this->options->fetchMode) && isset(self::$fetchModes[(string) $this->options->fetchMode])) {
$fetchMode = self::$fetchModes[(string) $this->options->fetchMode];
}
parent::$db->setFetchMode($fetchMode);
return parent::$db;
}
示例3: __construct
public function __construct($id = '')
{
parent::$db = self::$db;
parent::__construct($id);
}
示例4: init
public static function init()
{
global $discuz;
parent::$db = $discuz->db;
}