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


PHP Connection::connection方法代码示例

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


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

示例1: connect

 public function connect()
 {
     if (!self::$connection) {
         self::$connection = mysql_connect($this->server, $this->username, $this->password);
     }
     mysql_select_db($this->db);
 }
开发者ID:popytka008,项目名称:classes,代码行数:7,代码来源:Connection.php

示例2: getInstance

 public static function getInstance()
 {
     //get an instance of the connection
     if (Connection::$connection === NULL) {
         //if the connection is null
         // connect to the database local using the credentials
         $host = "localhost";
         $database = "CA1-TourBusMassacre";
         $username = "rorypb";
         $password = "root";
         // connection for college database
         //            $host = "daneel";
         //            $database = "N00143233playground";
         //            $username = "N00143233";
         //            $password = "N00143233";
         $dsn = "mysql:host=" . $host . ";dbname=" . $database;
         //url for connection
         Connection::$connection = new PDO($dsn, $username, $password);
         //Connection is made with the variables above
         if (!Connection::$connection) {
             //if there is no connection
             die("Could not connect to database");
             //die
         }
     }
     return Connection::$connection;
     //return the connection from the credentials above
 }
开发者ID:GitupPatsyy,项目名称:WEBPROGCA2,代码行数:28,代码来源:connection.php

示例3: getInstance

 public static function getInstance()
 {
     if (empty(self::$connection)) {
         self::$connection = new self();
         return self::$connection;
     }
 }
开发者ID:emaxv,项目名称:DataBase,代码行数:7,代码来源:connection.class.php

示例4: get

 public static function get()
 {
     if (self::$connection == false) {
         self::$connection = new PDO('mysql:host=' . self::$host . ';dbname=' . self::$dbname, self::$user, self::$pwd, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'', PDO::ATTR_CASE => 'SET lc_time_names = \'fr_FR\''));
         return self::$connection;
     } else {
         return self::$connection;
     }
 }
开发者ID:ThierryHund,项目名称:projet_conf,代码行数:9,代码来源:connection.class.php

示例5: open_connection

 protected static function open_connection()
 {
     //initialize connection
     self::$connection = new mysqli(self::$server, self::$user, self::$password, self::$database);
     //error in connection
     if (self::$connection->connect_errno) {
         echo 'Cannot connect to MySQL server : ' . self::$connection->connect_error;
         die;
     }
 }
开发者ID:Jczamarripa,项目名称:cars2015,代码行数:10,代码来源:connection.php

示例6: connect

 public function connect()
 {
     if (!isset(self::$connection)) {
         //Filen .ini innehåller databasuppkopplingsinfo som databasnamn, lösenord m.m.
         $config = parse_ini_file('./config.ini');
         //denna fil läggs utanför den mappar användare kan nå för att skydda databasinfo
         self::$connection = new mysqli('localhost', $config['username'], $config['password'], $config['dbname']);
     }
     return self::$connection;
 }
开发者ID:miahellqvist,项目名称:webbloppis,代码行数:10,代码来源:Connection.php

示例7: create

 public static function create($host, $dbname, $user, $pass)
 {
     if (self::$connection == null) {
         try {
             self::$connection = new PDO("mysql:host={$host};dbname={$dbname}", $user, $pass);
         } catch (PDOException $e) {
         }
     }
     return self::$connection;
 }
开发者ID:mmaydin,项目名称:peak,代码行数:10,代码来源:connection.php

示例8: connect

 /**
  * Connect to the database
  * 
  * @return bool false on failure / mysqli MySQLi object instance on success
  */
 public function connect()
 {
     if (!isset(self::$connection)) {
         $config = parse_ini_file(__DIR__ . '/../resources/dbconfig.ini');
         self::$connection = new mysqli($config['host'], $config['username'], $config['password'], $config['dbname']);
     }
     if (self::$connection === false) {
         return false;
     }
     return self::$connection;
 }
开发者ID:kaelvofraga,项目名称:Pedal-to-Play-Server,代码行数:16,代码来源:Connection.php

示例9: get

 /**
  * Get the connection to the database
  */
 public static function get()
 {
     if (self::$connection == false) {
         try {
             self::$connection = new PDO('mysql:host=' . self::$host . ';dbname=' . self::$dbname, self::$user, self::$pwd, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\'', PDO::ATTR_CASE => 'SET lc_time_names = \'de_DE\'', PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION));
             return self::$connection;
         } catch (Exception $e) {
             echo "erreur de connexion : " . $e->getMessage();
         }
     } else {
         return self::$connection;
     }
 }
开发者ID:MaximeBoubel,项目名称:cookinn,代码行数:16,代码来源:Connection.php

示例10: get

 public function get()
 {
     $sql = $this->_select;
     try {
         $db = parent::connection();
         $stmt = $db->query($sql);
         $result = $stmt->fetchAll(PDO::FETCH_OBJ);
         $db = null;
         echo json_encode($result);
     } catch (PDOException $e) {
         echo '{"error":{"text":' . $e->getMessage() . '}}';
     }
 }
开发者ID:jhonrsalcedo,项目名称:BSG,代码行数:13,代码来源:Email.php

示例11: getUser

 public function getUser($id)
 {
     $sql = $this->_select . " WHERE id = :id";
     try {
         $db = parent::connection();
         $stmt = $db->prepare($sql);
         $stmt->bindParam("id", $id);
         $stmt->execute();
         $result = $stmt->fetchObject();
         $db = null;
         echo json_encode($result);
     } catch (PDOException $e) {
         echo '{"error":{"text":' . $e->getMessage() . '}}';
     }
 }
开发者ID:jhonrsalcedo,项目名称:BSG,代码行数:15,代码来源:User.php

示例12: getInstance

 public static function getInstance()
 {
     if (Connection::$connection === NULL) {
         // connect to the database
         $host = "localhost";
         $database = "photo_gallery";
         $username = "root";
         $password = "";
         $dsn = "mysql:host=" . $host . ";dbname=" . $database;
         Connection::$connection = new PDO($dsn, $username, $password);
         if (!Connection::$connection) {
             die("Could not connect to database");
         }
     }
     return Connection::$connection;
 }
开发者ID:dylan18595,项目名称:Picter,代码行数:16,代码来源:Connection.php

示例13: get

 public function get()
 {
     $sql = $this->_select . " LIMIT 1";
     try {
         $db = parent::connection();
         $stmt = $db->prepare($sql);
         $stmt->execute();
         $result = $stmt->fetchObject();
         $db = null;
         $result->info = preg_replace("'\r?\n'", '', $result->info);
         $result->info = stripslashes($result->info);
         $result->info = stripcslashes($result->info);
         echo json_encode($result);
     } catch (PDOException $e) {
         echo '{"error":{"text":' . $e->getMessage() . '}}';
     }
 }
开发者ID:jhonrsalcedo,项目名称:BSG,代码行数:17,代码来源:Company.php

示例14: getInstance

 public static function getInstance()
 {
     if (Connection::$connection === NULL) {
         // connect to the database
         $host = "localhost";
         //logging into the database
         $db = "highland_books_database";
         $user = "JamieUser";
         $password = "Jamie";
         $dsn = "mysql:host=" . $host . ";dbname=" . $db;
         Connection::$connection = new PDO($dsn, $user, $password);
         if (!Connection::$connection) {
             die("Could not connect to database");
         }
     }
     return Connection::$connection;
 }
开发者ID:JamieHyland1,项目名称:Retail_Company_Web_Programming,代码行数:17,代码来源:Connection.php

示例15: descargaApk

 function descargaApk($array)
 {
     try {
         if ($array != NULL) {
             $con = new Connection();
             $mysql = $con->connection();
             $this->sql = "SELECT\n\t\t\t\taplicativo.ubicacion\n\t\t\t\tFROM usuarios\n\t\t\t\tINNER JOIN permisos on permisos.idUsuario = usuarios.id\n\t\t\t\tINNER JOIN aplicativo on aplicativo.id = permisos.idAplicativo\n\t\t\t\twhere\n\t\t\t\tusuarios.id = " . $array['usu'] . "\n\t\t\t\tand\n\t\t\t\taplicativo.id = " . $array['app'] . "\n\t\t\t\tand permisos.estado = 0";
             $resultado = mysql_query($this->sql);
             $fila = mysql_fetch_array($resultado);
             $con->disconnect($mysql);
         } else {
             $fila = $array;
         }
     } catch (Exception $e) {
         echo 'Excepción capturada: ', $e->getMessage(), "\n";
     }
     return $fila;
 }
开发者ID:Sebastianch7,项目名称:paginaWebAplicativosAndroid,代码行数:18,代码来源:Consult.php


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