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


PHP Connection::conn方法代码示例

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


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

示例1: testConexaoAoBancoDeDados

 public function testConexaoAoBancoDeDados()
 {
     $config = new Configurator(['dsn' => 'mysql:host=localhost;dbname=php_praticas_modernas', 'user' => 'root', 'pass' => '123', 'config' => []]);
     $conn = new Connection($config);
     $conn->conn();
     $pdo = $conn->getConn();
     $this->assertInstanceOf('PDO', $pdo);
 }
开发者ID:Raro01,项目名称:php-praticas-modernas-turma-1,代码行数:8,代码来源:ConnectionTest.php

示例2: __construct

 public function __construct($host, $user, $pass, $db)
 {
     //echo date_default_timezone_set('Africa/Lagos');
     $conn = mysqli_connect($host, $user, $pass, $db) or die("error");
     mysqli_query($conn, "SET time_zone = '+01:00' ") or die("SET TIMEZONE FAILED");
     self::$conn = $conn;
     return $conn;
 }
开发者ID:sheyooo,项目名称:gradeaccess,代码行数:8,代码来源:Connection.php

示例3: connect

 /**
  * @brief Function connect
  *      realiza a conexao.
  *      Utiliza strings: hostname, username, password e dbname, usando banco de dados 'mysqli', além de checar a conexao e seta-la no atributo 'conn'.
  * @param void
  * @return void
  */
 private static function connect()
 {
     $conn = new mysqli(self::$hostname, self::$username, self::$password, self::$dbname);
     if ($conn->connect_error) {
         die("<hr> Connection failed: " . $conn->connect_error);
     }
     self::$conn = $conn;
 }
开发者ID:cassiod,项目名称:SisAdm,代码行数:15,代码来源:Connection.class.php

示例4: testExecuteSelect

 public function testExecuteSelect()
 {
     $config = new Configurator(['dsn' => 'mysql:host=localhost;dbname=php_praticas_modernas', 'user' => 'root', 'pass' => '123', 'config' => []]);
     $conn = new Connection($config);
     $conn->conn();
     $select = new Mysql\Select();
     $execute = new Execute($conn);
     $execute->sql($select);
     $data = $execute->findAll();
     $esperado = [['id' => 1, 'name' => 'Erik', 'email' => 'contato@webdevbr.com.br']];
     $this->assertEquals($esperado, $data);
 }
开发者ID:Raro01,项目名称:php-praticas-modernas-turma-1,代码行数:12,代码来源:ExecuteTest.php

示例5: PDO

 function __construct($host, $db, $user, $pass)
 {
     $this->host = $host;
     $this->db = $db;
     $this->user = $user;
     $this->pass = $pass;
     try {
         self::$conn = new PDO('mysql:host=' . $host . ';dbname=' . $db . ';', $user, $pass);
         self::$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
         echo 'ERROR: ' . $e->getMessage();
     }
 }
开发者ID:nguyquan,项目名称:ps_api,代码行数:13,代码来源:connection.php

示例6: __construct

 public function __construct($host, $user, $pass, $db)
 {
     if (getenv('HEROKU')) {
         $url = parse_url(getenv("CLEARDB_DATABASE_URL"));
         $server = $url["host"];
         $username = $url["user"];
         $password = $url["pass"];
         $db = substr($url["path"], 1);
         $conn = new mysqli($server, $username, $password, $db);
         mysqli_query($conn, "SET time_zone = '+01:00' ") or die("SET TIMEZONE FAILED");
         self::$conn = $conn;
     } else {
         //echo date_default_timezone_set('Africa/Lagos');
         $conn = mysqli_connect($host, $user, $pass, $db) or die("error");
         mysqli_query($conn, "SET time_zone = '+01:00' ") or die("SET TIMEZONE FAILED");
         self::$conn = $conn;
     }
     return $conn;
 }
开发者ID:sheyooo,项目名称:testify,代码行数:19,代码来源:Connection.php


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