当前位置: 首页>>代码示例>>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;未经允许,请勿转载。