本文整理汇总了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);
}
示例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);
}
示例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);
}
示例4: setNewSport
public function setNewSport($cz)
{
$db = parent::connect();
$result = $db->prepare("INSERT INTO `sport`(`cz`) VALUES ( ? )");
$result->execute(array($cz));
return $db->lastInsertId();
}
示例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;
}
示例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');
}
示例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));
}
示例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';
}
}
}
示例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;
}
}
示例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();
}
示例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;
}
示例12: getConnection
public static function getConnection()
{
if (!isset(self::$connect)) {
self::$connect = new Connection();
}
return self::$connect;
}
示例13: run
public static function run()
{
Connection::connect();
Session::start();
Router::run();
Connection::disconnect();
}
示例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;
}
示例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;
}