本文整理汇总了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;
}