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


PHP Connection::instance方法代码示例

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


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

示例1: get

 public static function get()
 {
     if (is_null(self::$instance)) {
         self::$instance = self::openConnection();
     }
     return self::$instance;
 }
开发者ID:carlosrodriguesf,项目名称:adeushomonios,代码行数:7,代码来源:Connection.class.php

示例2: getInstance

 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         self::$instance = new Connection();
     }
     return self::$instance;
 }
开发者ID:nathanfl,项目名称:medtele,代码行数:7,代码来源:Connection.Class.php

示例3: get_instance

 /**
  * Get a singleton instance of Connection<object>
  *
  * @return Connection
  */
 public static function get_instance()
 {
     if (self::$instance === null) {
         self::$instance = new Connection();
     }
     return self::$instance;
 }
开发者ID:sook,项目名称:drumon_framework,代码行数:12,代码来源:connection.php

示例4: open

 public static function open()
 {
     if (self::$instance == null) {
         $klass = __CLASS__;
         self::$instance = new $klass('localhost', 'root', "", 'impaz');
     }
     return self::$instance;
 }
开发者ID:worker-8,项目名称:PaginaClienteMarcel_VENTA-ROPA,代码行数:8,代码来源:connection.php

示例5: getInstance

 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self(self::HOST, self::USER, self::PASSWORD, self::DATABASE);
         self::$instance->query("SET NAMES 'utf8'");
     }
     return self::$instance;
 }
开发者ID:nikobm90,项目名称:cineUTN,代码行数:8,代码来源:connection.php

示例6: instance

 public static function instance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
开发者ID:klawdyo,项目名称:spaghettiphp,代码行数:8,代码来源:Connection.php

示例7: getInstance

 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
         self::$instance = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_SCHEMA, DB_USERNAME, DB_PASSWORD, $pdo_options);
     }
     return self::$instance;
 }
开发者ID:rahmanadianto,项目名称:IF3110-2015-T1,代码行数:8,代码来源:class.connection.php

示例8: get_connection

 /**
  * If $name is null then the default connection will be returned.
  *
  * @see Config
  * @param string $name Optional name of a connection
  * @return Connection
  */
 public static function get_connection($name = null)
 {
     $config = Config::instance();
     $name = $name ? $name : $config->get_default_connection();
     if (!isset(self::$connections[$name]) || !self::$connections[$name]->connection) {
         self::$connections[$name] = Connection::instance($config->get_connection($name));
     }
     return self::$connections[$name];
 }
开发者ID:bobseven,项目名称:bootstrap-codeignitor,代码行数:16,代码来源:ConnectionManager.php

示例9: __construct

 private function __construct()
 {
     try {
         self::$instance = new PDO('mysql:host=localhost;port=3306;dbname=biblioteca;charset=utf8', 'root', 'qwe123');
         self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     } catch (PDOException $e) {
         die("Erro no banco de dados: " . $e->getMessage());
     }
 }
开发者ID:alanfm,项目名称:biblioteca,代码行数:9,代码来源:Connection.php

示例10: __construct

 /**
  * Constuctor de la clase haciendo uso del patrón Singletón
  * @return Connection
  */
 public function __construct()
 {
     if (!self::$instance) {
         $this->loadProxyMySql();
         $this->loadProxySoap();
         self::$instance = $this;
     }
     return self::$instance;
 }
开发者ID:fur81,项目名称:zofaxiopeu,代码行数:13,代码来源:connection.php

示例11: remove

 public function remove($table, $columns, $options = array())
 {
     $name = $this->getName($columns, $options);
     if ($name === 'PRIMARY') {
         $sql = "ALTER TABLE `{$table}` DROP PRIMARY KEY";
     } else {
         $sql = "ALTER TABLE `{$table}` DROP INDEX `{$name}`";
     }
     return Connection::instance()->execute($sql);
 }
开发者ID:nanjingboy,项目名称:clown,代码行数:10,代码来源:Index.php

示例12: __construct

 private function __construct()
 {
     try {
         Connection::$instance = new PDO("mysql:host={$this->servername};dbname={$this->dbName}", $this->username, $this->password);
         // set the PDO error mode to exception
         Connection::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         echo "Connected successfully";
     } catch (PDOException $e) {
         echo "Connection failed: " . $e->getMessage();
     }
 }
开发者ID:akbars95,项目名称:phpProjects,代码行数:11,代码来源:Connection.php

示例13: getInstance

 /**
  * Singleton method that requests a unique instance of the class
  *
  * @return object (PDO)
  * @access public
  */
 public static function getInstance()
 {
     if (!self::$instance instanceof self) {
         try {
             self::$instance = new self();
             self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         } catch (PDOException $e) {
             echo 'Connection failed: ' . $e->getMessage();
         }
     }
     return self::$instance;
 }
开发者ID:googlecode-mirror,项目名称:balrog,代码行数:18,代码来源:Connection.class.php

示例14: getInstance

 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         try {
             self::$instance = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS);
             self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
             self::$instance->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
         } catch (PDOException $e) {
             echo $e->getMessage();
         }
     }
     return self::$instance;
 }
开发者ID:czucherato,项目名称:camuswsecommerce,代码行数:13,代码来源:Connection.php

示例15: remove

 public function remove($table)
 {
     return Connection::instance()->execute("DROP TABLE `{$table}`");
 }
开发者ID:nanjingboy,项目名称:clown,代码行数:4,代码来源:Table.php


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