當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connection::connect方法代碼示例

本文整理匯總了PHP中Connection::connect方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connection::connect方法的具體用法?PHP Connection::connect怎麽用?PHP Connection::connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Connection的用法示例。


在下文中一共展示了Connection::connect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 /**
  * @return null
  */
 public function setUp()
 {
     $this->runDbStartupTask();
     $connector = DbRegistry::getConnector('af-tester');
     $this->conn = $connector->getConnection();
     $this->conn->connect();
     $driver = $this->conn->getDriver();
     $this->stmtDriver = $driver->stmt_init();
     $this->stmt = new PreparedStmt($this->stmtDriver);
 }
開發者ID:kevinlondon,項目名稱:appfuel,代碼行數:13,代碼來源:PreparedStmtTest.php

示例2: connect

 /**
  * connect()
  */
 public function connect($dsninfo, $flags = 0)
 {
     if (!($driver = Creole::getDriver($dsninfo['phptype']))) {
         throw new SQLException("No driver has been registered to handle connection type: {$type}");
     }
     $connectionClass = Creole::import($driver);
     $this->childConnection = new $connectionClass();
     $this->log("connect(): DSN: " . var_export($dsninfo, true) . ", FLAGS: " . var_export($flags, true));
     return $this->childConnection->connect($dsninfo, $flags);
 }
開發者ID:rodrigoprestesmachado,項目名稱:whiteboard,代碼行數:13,代碼來源:DebugConnection.php

示例3: testConnection

 public function testConnection()
 {
     $this->subject->disconnect();
     $result = $this->subject->connect();
     $this->assertTrue($result);
     // Try a reconnect
     $result = $this->subject->connect();
     $this->assertTrue($result);
     $result = $this->subject->isConnected();
     $this->assertTrue($result);
     $result = $this->subject->disconnect();
     $this->assertTrue($result);
     $result = $this->subject->isConnected();
     $this->assertFalse($result);
 }
開發者ID:samjarrett,項目名稱:beanstalk,代碼行數:15,代碼來源:ConnectTest.php

示例4: setNewSport

 public function setNewSport($cz)
 {
     $db = parent::connect();
     $result = $db->prepare("INSERT INTO `sport`(`cz`) VALUES ( ? )");
     $result->execute(array($cz));
     return $db->lastInsertId();
 }
開發者ID:ununik,項目名稱:tiary,代碼行數:7,代碼來源:Sport.class.php

示例5: getAllEntryForAuthor

 public function getAllEntryForAuthor($author)
 {
     $result = parent::connect()->prepare("SELECT * FROM `entries` WHERE `author` = :id AND `active` = 1 ORDER BY `id` DESC");
     $result->execute(array(':id' => $author));
     $pageResult = $result->fetchAll();
     return $pageResult;
 }
開發者ID:ununik,項目名稱:kvhusti,代碼行數:7,代碼來源:Entry.class.php

示例6: setUp

 protected function setUp()
 {
     $host = getenv('TEST_BEANSTALKD_HOST');
     $port = getenv('TEST_BEANSTALKD_PORT');
     if (!$host || !$port) {
         $message = 'TEST_BEANSTALKD_HOST and/or TEST_BEANSTALKD_PORT env variables not defined.';
         $this->markTestSkipped($message);
     }
     $connection = new Connection($host, $port, false);
     if (!$connection->connect()) {
         $message = "Need a running beanstalkd server at {$host}:{$port}.";
         $this->markTestSkipped($message);
     }
     $this->subject = new Client($connection);
     // Clear all jobs on the server
     foreach ($this->subject->listTubes() as $tube) {
         $this->subject->useTube($tube);
         while ($job = $this->subject->peekReady()) {
             $this->subject->delete($job['id']);
         }
         while ($job = $this->subject->peekBuried()) {
             $this->subject->delete($job['id']);
         }
     }
     $this->subject->useTube('default');
 }
開發者ID:samjarrett,項目名稱:beanstalk,代碼行數:26,代碼來源:ProducerTest.php

示例7: setNewImg

 public function setNewImg($name, $size, $user, $type)
 {
     $db = parent::connect();
     $timestamp = time();
     $result = $db->prepare("INSERT INTO `profile_image`(`name`, `timestamp`, `size`, `user`, `type`) VALUES (?, ?, ?, ?, ?)");
     $result->execute(array($name, $timestamp, $size, $user, $type));
 }
開發者ID:ununik,項目名稱:tiary,代碼行數:7,代碼來源:ProfileImage.class.php

示例8: posicionaApps

function posicionaApps($conf_apps)
{
    $colunas = explode('|', $conf_apps);
    foreach ($colunas as $chave => $coluna) {
        $apps = explode(',', $coluna);
        // Carrega estrutura HTML auxiliar
        if ($chave == 0) {
            require_once 'assets/htmls_auxiliares/html_box-esquerdo.php';
        }
        if ($chave == 1) {
            require_once 'assets/htmls_auxiliares/html_box-meio.php';
        }
        if ($chave == 2) {
            require_once 'assets/htmls_auxiliares/html_box-direito.php';
        }
        // Carrega cada app separadamente
        $connect = Connection::connect();
        foreach ($apps as $app) {
            if (!empty($app)) {
                require 'apps/' . $app . '.php';
            }
        }
        // Carrega estrutura HTML auxiliar
        if ($chave == 0) {
            require_once 'assets/htmls_auxiliares/html_fim_box-esquerdo.php';
        }
        if ($chave == 1) {
            require_once 'assets/htmls_auxiliares/html_fim_box-meio.php';
        }
        if ($chave == 2) {
            require_once 'assets/htmls_auxiliares/html_fim_box-direito.php';
        }
    }
}
開發者ID:raigons,項目名稱:bureauinteligencia,代碼行數:34,代碼來源:carrega_apps.php

示例9: tryMethod

 private function tryMethod($method, $args)
 {
     try {
         return call_user_func_array([$this->connection, $method], $args);
     } catch (\Exception $exception) {
         $e = $exception;
         while ($e->getPrevious() && !$e instanceof \PDOException) {
             $e = $e->getPrevious();
         }
         if ($e instanceof \PDOException && $e->errorInfo[1] == self::MYSQL_CONNECTION_TIMED_WAIT_CODE) {
             $this->connection->close();
             $this->connection->connect();
             $this->logger->notice('Connection to MySQL lost, reconnect okay.');
             return call_user_func_array([$this->connection, $method], $args);
         }
         if (false !== strpos($exception->getMessage(), 'MySQL server has gone away') || false !== strpos($exception->getMessage(), 'Error while sending QUERY packet') || false !== strpos($exception->getMessage(), 'errno=32 Broken pipe')) {
             $this->connection->close();
             $this->connection->connect();
             $this->logger->notice('Connection to MySQL lost, reconnect okay.');
             return call_user_func_array([$this->connection, $method], $args);
         }
         $this->logger->critical('Connection to MySQL lost, unable to reconnect.', ['exception' => $exception]);
         throw $e;
     }
 }
開發者ID:luisbrito,項目名稱:Phraseanet,代碼行數:25,代碼來源:ReconnectableConnection.php

示例10: login

 function login($email, $password)
 {
     $mysqli = new Connection();
     $db = $mysqli->connect();
     //hash the password
     $password = hashPassword($password);
     //prepare the query
     $query = $db->prepare("SELECT id FROM users WHERE email = ? AND password = ? LIMIT 1") or die("error");
     $query->bind_param('ss', $email, $password);
     //excuting
     $query->execute();
     //store results
     $query->store_result();
     //bind results
     $query->bind_result($id);
     $query->fetch();
     //get the num rows
     if ($query->num_rows == 1) {
         $user_browser = $_SERVER['HTTP_USER_AGENT'];
         session_start();
         $_SESSION['login_string'] = array();
         $_SESSION['login_string']['browserInfo'] = hash('sha512', $user_browser);
         $_SESSION['login_string']['id'] = hash('sha512', $id);
         return TRUE;
     } else {
         return FALSE;
     }
     //close the query
     $db->close();
 }
開發者ID:j3rin,項目名稱:Login,代碼行數:30,代碼來源:Auth.php

示例11: getDBContent

 public function getDBContent($page)
 {
     $result = parent::connect()->prepare("SELECT * FROM `pages` WHERE `url_name` = :page LIMIT 1");
     $result->execute(array(':page' => $page));
     $pageResult = $result->fetch();
     return $pageResult;
 }
開發者ID:ununik,項目名稱:kvhusti,代碼行數:7,代碼來源:Page.class.php

示例12: getConnection

 public static function getConnection()
 {
     if (!isset(self::$connect)) {
         self::$connect = new Connection();
     }
     return self::$connect;
 }
開發者ID:noikiy,項目名稱:lovetolove,代碼行數:7,代碼來源:Connection.php

示例13: run

 public static function run()
 {
     Connection::connect();
     Session::start();
     Router::run();
     Connection::disconnect();
 }
開發者ID:albertomoreno,項目名稱:web-newspaper,代碼行數:7,代碼來源:App.php

示例14: getNahravkaAll

 public function getNahravkaAll()
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `nahravka` ORDER BY `id` DESC");
     $result->execute(array());
     $nahravka = $result->fetchAll();
     return $nahravka;
 }
開發者ID:ununik,項目名稱:marek_prosner,代碼行數:8,代碼來源:Nahravka.class.php

示例15: getEnroll

 public function getEnroll($event)
 {
     $db = parent::connect();
     $result = $db->prepare("SELECT * FROM `enroll` WHERE event = ?");
     $result->execute(array($event));
     $event = $result->fetchAll();
     return $event;
 }
開發者ID:ununik,項目名稱:tiary,代碼行數:8,代碼來源:Enroll.class.php


注:本文中的Connection::connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。