本文整理汇总了PHP中Conexao::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Conexao::instance方法的具体用法?PHP Conexao::instance怎么用?PHP Conexao::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Conexao
的用法示例。
在下文中一共展示了Conexao::instance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public static function init()
{
if (is_null(self::$instance)) {
self::$instance = new Conexao();
}
return self::$instance;
}
示例2: getInstance
public function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new PDO("mysql:host=localhost;dbname=mestrado", "root", "");
}
return self::$instance;
}
示例3: fecharConexao
public function fecharConexao()
{
if ($this->status) {
$this->connection->close();
self::$instance = null;
$this->status = false;
}
}
示例4: getInstance
public static function getInstance()
{
if (!isset(self::$instance)) {
self::$instance = new PDO('mysql:host=localhost;dbname=controle_empresarial', 'root', '', array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
self::$instance->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING);
}
return self::$instance;
}
示例5: getInstance
public static function getInstance()
{
$host = 'localhost';
$dbname = 'nfe';
$user = 'root';
$psw = '';
if (!isset(self::$instance)) {
self::$instance = new PDO('mysql:host=' . $host . ';dbname=' . $dbname, $user, $psw, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
self::$instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
self::$instance->setAttribute(PDO::ATTR_ORACLE_NULLS, PDO::NULL_EMPTY_STRING);
}
return self::$instance;
}
示例6: 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, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
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;
}
示例7: close
/**
* Fecha a instancia de conexao ao banco de dados
*/
public static function close()
{
if (self::$instance != null) {
self::$instance = null;
}
}