当前位置: 首页>>代码示例>>PHP>>正文


PHP DataSource::connect方法代码示例

本文整理汇总了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;
 }
开发者ID:bd808,项目名称:casadebender,代码行数:37,代码来源:MySQLDataSource.php

示例2: connect

 /**
  * "Connect" to the user input.
  * @return TRUE is successful, FALSE otherwise.
  */
 function connect()
 {
     if (!parent::connect()) {
         return !is_null($_REQUEST);
     }
     return TRUE;
 }
开发者ID:bd808,项目名称:casadebender,代码行数:11,代码来源:UserInputDataSource.php

示例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);
 }
开发者ID:bd808,项目名称:casadebender,代码行数:9,代码来源:ChunsuObject.php


注:本文中的DataSource::connect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。