當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。