本文整理汇总了PHP中DataSource::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP DataSource::connect方法的具体用法?PHP DataSource::connect怎么用?PHP DataSource::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataSource
的用法示例。
在下文中一共展示了DataSource::connect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
/**
* Connect to the MySQL data source, looks for the following
* configuration options.
* <ul>
* <li>server - The hostname or IP address of the MySQL DB
* server.</li>
* <li>username - The username on the MySQL database.</li>
* <li>password - The password on the MySQL database.</li>
* </ul>
* @return TRUE is successful, FALSE otherwise (though this is
* unlikely to occur because of the fatal error event when the
* connection fails).
*/
function connect()
{
if (!parent::connect()) {
$username = $this->config->get('username');
if (!is_string($username)) {
$username = get_current_user();
$this->config->warn("MySQL username is not specified, using the user " . "of the PHP process ({$username}). This may be " . "ambiguous, consider setting the 'username' " . "configuration option.");
}
if (!($this->myLink = mysql_connect($this->config->get('server'), $username, $this->config->get('password')))) {
LogFatal("Unable to establish MySQL connetion: " . mysql_error());
return FALSE;
}
$database = $this->config->get('database');
if (!is_string($database)) {
$this->config->warn("MySQL database name is not specified, using the " . "username ({$username}) as the database name. This " . "may be ambiguous, consider setting the 'database' " . "configuration option.");
$database = $username;
}
if (!mysql_select_db($database, $this->myLink)) {
LogFatal("Unable to select MySQL database: " . mysql_error());
return FALSE;
}
}
return TRUE;
}
示例2: connect
/**
* "Connect" to the user input.
* @return TRUE is successful, FALSE otherwise.
*/
function connect()
{
if (!parent::connect()) {
return !is_null($_REQUEST);
}
return TRUE;
}
示例3: import
/**
* Import data from a data source into this object's change set.
* @param DataSource $ds alternate data source to use.
*/
function import(&$ds)
{
$ds->connect();
$this->storage_method->import($this, $ds);
}