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


PHP DatabaseConnection::connect方法代码示例

本文整理汇总了PHP中DatabaseConnection::connect方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection::connect方法的具体用法?PHP DatabaseConnection::connect怎么用?PHP DatabaseConnection::connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DatabaseConnection的用法示例。


在下文中一共展示了DatabaseConnection::connect方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: connect

 /**
  * Extends default connection method. It will be useful in order to
  * allow accents and other DB-centric global commands.
  *
  * @param string $connect_string a PDO connection string
  * @param string $db_user the database user name
  * @param string $db_pass the database user password
  * @return boolean TRUE on success, FALSE on error
  */
 public function connect($connect_string, $db_user, $db_pass)
 {
     // If something went wrong, we don't need to exec the specific commands.
     if (!parent::connect($connect_string, $db_user, $db_pass)) {
         return false;
     }
     return true;
 }
开发者ID:psaintlaurent,项目名称:Habari,代码行数:17,代码来源:connection.php

示例2: openConnection

 protected static final function openConnection($driver)
 {
     $adapter = 'Adapter' . $driver;
     include_once dirname(__FILE__) . '/adapter/' . $adapter . '.php';
     $connection = new DatabaseConnection(new $adapter());
     $cfg = self::getConnectionConf();
     $connection->connect($cfg['engine'], $cfg['hostname'], $cfg['database'], $cfg['username'], $cfg['password']);
     return $connection;
     // end function
 }
开发者ID:dlehmann,项目名称:DevCE,代码行数:10,代码来源:Database.php

示例3: connect

 /**
  * Extends default connection method. It will be useful in order to
  * allow accents and other DB-centric global commands.
  *
  * @param string $connect_string a PDO connection string
  * @param string $db_user the database user name
  * @param string $db_pass the database user password
  * @return boolean TRUE on success, FALSE on error
  */
 public function connect($connect_string, $db_user, $db_pass)
 {
     // If something went wrong, we don't need to exec the specific commands.
     if (!parent::connect($connect_string, $db_user, $db_pass)) {
         return false;
     }
     $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
     // Everything is OK. Let's update the charset!
     if (!defined('MYSQL_CHAR_SET')) {
         define('MYSQL_CHAR_SET', 'UTF8');
     }
     $this->exec('SET NAMES ' . MYSQL_CHAR_SET);
     return true;
 }
开发者ID:anupom,项目名称:my-blog,代码行数:23,代码来源:connection.php

示例4: connect

 /**
  * Extends default connection method. It will be useful in order to
  * allow accents and other DB-centric global commands.
  *
  * @param string $connect_string a PDO connection string
  * @param string $db_user the database user name
  * @param string $db_pass the database user password
  * @return boolean true on success, false on error
  */
 public function connect($connect_string, $db_user, $db_pass)
 {
     // If something went wrong, we don't need to exec the specific commands.
     if (!parent::connect($connect_string, $db_user, $db_pass)) {
         return false;
     }
     $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
     // Everything is OK. Let's update the charset!
     if (!defined('MYSQL_CHAR_SET')) {
         define('MYSQL_CHAR_SET', 'UTF8');
     }
     // SET NAMES defines character_set_client, character_set_results, and character_set_connection (which implicitly sets collation_connection) and therefore covers everything SET CHARACTER SET does, but uses the character set we tell it to, ignoring what the database is configured to use
     // 	http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html
     $this->exec('SET NAMES ' . MYSQL_CHAR_SET);
     return true;
 }
开发者ID:wwxgitcat,项目名称:habari,代码行数:25,代码来源:connection.php

示例5: connect

 /**
  * Extends default connection method. It will be useful in order to
  * allow accents and other DB-centric global commands.
  *
  * @param string $connect_string a PDO connection string
  * @param string $db_user the database user name
  * @param string $db_pass the database user password
  * @return boolean true on success, false on error
  */
 public function connect($connect_string, $db_user, $db_pass)
 {
     // If something went wrong, we don't need to exec the specific commands.
     if (!parent::connect($connect_string, $db_user, $db_pass)) {
         return false;
     }
     $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
     // Everything is OK. Let's update the charset!
     if (!defined('MYSQL_CHAR_SET')) {
         define('MYSQL_CHAR_SET', 'UTF8');
     }
     // SET CHARACTER SET might get the character_set_connection wrong, thus we also need SET NAMES. See http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html
     $this->exec('SET CHARACTER SET ' . MYSQL_CHAR_SET);
     $this->exec('SET NAMES ' . MYSQL_CHAR_SET);
     return true;
 }
开发者ID:ringmaster,项目名称:system,代码行数:25,代码来源:connection.php

示例6: isAlreadyRegistered

 /**
  * @param $email
  * @return bool
  */
 public function isAlreadyRegistered($email)
 {
     //require_once "classes/DatabaseConnection.php";
     /**
      * Get user by email and password
      */
     try {
         $databaseHandle = new DatabaseConnection();
         $connection = $databaseHandle->connect();
         //establish connection to the database
         $statement = $connection->prepare("SELECT * FROM " . TABLE_NAME . " WHERE _email=?");
         $statement->bindParam(1, $email);
         $statement->execute();
         //check if the operation was successful
         if ($statement->rowCount() > 0) {
             return $statement;
         }
     } catch (PDOException $exception) {
         echo $exception->getMessage();
     }
     return false;
 }
开发者ID:uazahar,项目名称:Logix,代码行数:26,代码来源:DatabaseOperation.php

示例7: mt_connect

 /**
  * Attempt to connect to the Movable Type database
  *
  * @access private
  * @param string $db_host The hostname of the MT database
  * @param string $db_name The name of the MT database
  * @param string $db_user The user of the MT database
  * @param string $db_pass The user's password for the MT database
  * @param string $db_prefix The table prefix for the MT instance in the database
  * @return mixed false on failure, DatabseConnection on success
  */
 private function mt_connect($db_host, $db_name, $db_user, $db_pass, $db_prefix)
 {
     // Connect to the database or return false
     try {
         $mtdb = new DatabaseConnection();
         $mtdb->connect("mysql:host={$db_host};dbname={$db_name}", $db_user, $db_pass, $db_prefix);
         return $mtdb;
     } catch (Exception $e) {
         return false;
     }
 }
开发者ID:habari-extras,项目名称:mtimport,代码行数:22,代码来源:mtimport.plugin.php

示例8: DomainManager

<?php

include $_SERVER['DOCUMENT_ROOT'] . '/cabinet/backend/class/reptilicus.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/cabinet/backend/web/domain_manager.php';
$dm = new DomainManager();
if ($dm->isCustomDomain()) {
    include $_SERVER['DOCUMENT_ROOT'] . '/cabinet/backend/tpl/index.php';
    return;
}
$db = new DatabaseConnection();
$dbconn = $db->connect();
$reptilucText = new reptilucText();
$text = $reptilucText->getTextEn($dbconn, 1);
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Login page</title>
  <meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0 initial-scale=1.0">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" 
  integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/alertify.js/0.3.11/alertify.core.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/alertify.js/0.3.11/alertify.default.min.css">
  <link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.min.css">

  <link rel="stylesheet" href="css/login.css">
</head>
<body ng-app="login" ng-controller="mainCtrl as main">
  <div class="login_container">
    <div id="reptilicus-login-form">
开发者ID:vinchik,项目名称:angular_tracking,代码行数:31,代码来源:login.php

示例9: test

 /**
  * Tests whether a connection can be established.
  *
  * @param string $host
  * @param int    $port
  * @param string $dbname
  * @param string $user
  * @param string $password
  * @return mixed `true` or {@link \PDOException}
  */
 public static function test($host, $port, $dbname, $user, $password)
 {
     try {
         $conn = new DatabaseConnection($host, $port);
         $conn->init($dbname);
         $conn->connect($user, $password);
         return true;
     } catch (\PDOException $e) {
         return $e;
     }
 }
开发者ID:tniessen,项目名称:tinyIt,代码行数:21,代码来源:DatabaseConnection.php

示例10: s9y_connect

 /**
  * Attempt to connect to the Serendipity database
  *
  * @param string $db_host The hostname of the WP database
  * @param string $db_name The name of the WP database
  * @param string $db_user The user of the WP database
  * @param string $db_pass The user's password for the WP database
  * @param string $db_prefix The table prefix for the WP instance in the database
  * @param string $db_port The port number of the WP database
  * @return mixed false on failure, DatabseConnection on success
  */
 private function s9y_connect($db_host, $db_name, $db_user, $db_pass, $db_prefix, $db_port = null)
 {
     // Connect to the database or return false
     try {
         $s9ydb = new DatabaseConnection();
         $connect_str = "mysql:host={$db_host};dbname={$db_name}";
         if (!is_null($db_port)) {
             $connect_str .= ";port={$db_port}";
         }
         $s9ydb->connect($connect_str, $db_user, $db_pass, $db_prefix);
         return $s9ydb;
     } catch (PDOException $e) {
         return FALSE;
     }
 }
开发者ID:habari-extras,项目名称:s9yimport,代码行数:26,代码来源:s9yimport.plugin.php


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