本文整理汇总了PHP中MDB::Connect方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB::Connect方法的具体用法?PHP MDB::Connect怎么用?PHP MDB::Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB
的用法示例。
在下文中一共展示了MDB::Connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _connect
/**
* Connect to database by using the given DSN string
*
* @access private
* @param string DSN string
* @return mixed Object on error, otherwise bool
*/
function _connect($dsn)
{
if (is_string($dsn) || is_array($dsn)) {
$this->db =& MDB::Connect($dsn);
} elseif (get_parent_class($dsn) == "mdb_common") {
$this->db = $dsn;
} elseif (is_object($dsn) && MDB::isError($dsn)) {
return PEAR::raiseError($dsn->getMessage(), $dsn->code);
} else {
return PEAR::raiseError('The given dsn was not valid in file ' . __FILE__ . ' at line ' . __LINE__, 41, PEAR_ERROR_RETURN, null, null);
}
if (MDB::isError($this->db) || PEAR::isError($this->db)) {
return PEAR::raiseError($this->db->getMessage(), $this->db->code);
} else {
return true;
}
}
示例2: Cache_Container_mdb
/**
* Constructor
*
* @param mixed Array with connection info or dsn string
*/
function Cache_Container_mdb($options)
{
$this->db =& MDB::Connect($options);
if (MDB::isError($this->db)) {
return new Cache_Error('MDB::connect failed: ' . $this->db->getMessage(), __FILE__, __LINE__);
} else {
$this->db->setFetchMode(MDB_FETCHMODE_ASSOC);
}
$this->setOptions($options, array_merge($this->allowed_options, array('dsn', 'cache_table')));
}
示例3: Mail_Queue_Container_mdb
/**
* Contructor
*
* Mail_Queue_Container_mdb:: Mail_Queue_Container_mdb()
*
* @param mixed $options An associative array of option names and
* their values. See MDB_common::setOption
* for more information about connection options.
*
* @access public
*/
function Mail_Queue_Container_mdb($options)
{
if (!is_array($options)) {
return new Mail_Queue_Error(MAILQUEUE_ERROR_NO_OPTIONS, $this->pearErrorMode, E_USER_ERROR, __FILE__, __LINE__, 'No options specified!');
}
if (isset($options['mail_table'])) {
$this->mail_table = $options['mail_table'];
unset($options['mail_table']);
}
if (isset($options['sequence'])) {
$this->sequence = $options['sequence'];
unset($options['sequence']);
} else {
$this->sequence = $this->mail_table;
}
if (!empty($options['pearErrorMode'])) {
$this->pearErrorMode = $options['pearErrorMode'];
}
if (isset($options['dsn'])) {
$dsn = $options['dsn'];
} else {
$dsn = $options;
}
$this->db =& MDB::Connect($dsn);
if (MDB::isError($this->db)) {
return new Mail_Queue_Error(MAILQUEUE_ERROR_CANNOT_CONNECT, $this->pearErrorMode, E_USER_ERROR, __FILE__, __LINE__, 'MDB::connect failed: ' . $this->db->getMessage());
} else {
$this->db->setFetchMode(MDB_FETCHMODE_ASSOC);
}
$this->setOption();
}