本文整理汇总了PHP中MDB2::getMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP MDB2::getMessage方法的具体用法?PHP MDB2::getMessage怎么用?PHP MDB2::getMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDB2
的用法示例。
在下文中一共展示了MDB2::getMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* The options are:
* - debug_level: level of debug if it's not specified it's set by debugObject to DEBUG_DEFAULT_LEVEL
* - dsn: the Data Source Name to connect to a database through PEAR::MDB2 {@link http://pear.php.net/manual/en/package.database.mdb2.intro-dsn.php}.
* The DSN must be provided as an associative array or as a string.
* The array format is preferred, since it doesn't require a further parsing step (see the {@link http://pear.php.net/manual/en/package.database.mdb2.intro-connect.php Connecting
* chapter} for an example). The string format of the supplied DSN is in its fullest form:
* phptype(dbsyntax)://username:password@protocol+hostspec/database?option=value
* Examples:
* $dsn = 'mysqli://themaster:thepowerofthepower@localhost/masterdb'
* $dsn = array(
* 'phptype' => 'mysqli',
* 'username' => 'themaster',
* 'password' => 'thepowerofthepower',
* 'hostspec' => 'localhost',
* 'database' => 'masterdb'
* );
* - mdb2_options: can contain runtime configuration settings for the MDB2 package (see the {@link http://pear.php.net/manual/en/package.database.mdb2.intro-connect.php Connecting} for more details).
* - table: the name of the table where debug logs are stored.
*
* @param array $options
* @throws BadMethodCallException
* @throws exceptions
*/
public function __construct($options = null)
{
$this->_dsn = isset($options['dsn']) ? $options['dsn'] : DEBUG_DEFAULT_MYSQL_DSN;
$this->_table = isset($options['table']) ? $options['table'] : DEBUG_DEFAULT_MYSQL_TABLE;
$this->_mdb2_options = isset($options['mdb2_options']) ? $options['mdb2_options'] : array();
parent::__construct($options);
$this->_mdb2 =& MDB2::factory($this->_dsn, $this->_mdb2_options);
if (PEAR::isError($this->_mdb2)) {
throw new exceptions($this->_mdb2->getMessage(), $this->_mdb2->getCode());
}
}
示例2: Connect
public function Connect()
{
if ($this->_connected && !is_null($this->_db)) {
return;
}
$dsn = array('phptype' => $this->_dbType, 'username' => $this->_dbUser, 'password' => $this->_dbPassword, 'hostspec' => $this->_hostSpec, 'database' => $this->_dbName);
$options = array('debug' => 0, 'portability' => MDB2_PORTABILITY_ALL, 'persistent' => true);
$this->_db =& MDB2::connect($dsn, $options);
if (MDB2::isError($this->_db)) {
// If there is an error, print to browser, print to logfile and kill app
throw new Exception("Error connecting to database\nError: " . $this->_db->getMessage() . "\nDebug: " . $this->_db->getDebugInfo());
// TODO: LOG
}
$this->_db->setFetchMode(MDB2_FETCHMODE_ASSOC);
// Set fetch mode to return associatve array
$this->_connected = true;
}