note 124348 added to pdo.connections

From: Date: Mon, 28 Oct 2019 15:50:10 +0000
Subject: note 124348 added to pdo.connections
Groups: php.notes 
Request: Send a blank email to php-notes+get-212864@lists.php.net to get a copy of this message
<?php namespace classes; use PDO; class Database { protected static $db; private function __construct($banco) { $db_host = 'localhost'; $db_nome = $banco; $db_usuario = 'root'; $db_senha = 'root'; $db_driver = 'mysql'; try { self::$db = new PDO("$db_driver:host=$db_host; dbname=$db_nome", $db_usuario, $db_senha); self::$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); self::$db->exec('SET NAMES utf8'); } catch (\PDOException $e) { echo 'Error connecting to MySQL: ' . $e->getMessage(); die("Connection Error: " . $e->getMessage()); } } public static function connectionDB($banco) { if (!self::$db) { new Database($banco); } return self::$db; } } ---- Server IP: 208.43.231.9 Probable Submitter: 82.199.157.54 (proxied: 2804:29b8:1003:96:2445:3965:97af:d8fb) ---- Manual Page -- http://php.net/manual/en/pdo.connections.php Edit -- https://master.php.net/note/edit/124348 Del: integrated -- https://master.php.net/note/delete/124348/integrated Del: useless -- https://master.php.net/note/delete/124348/useless Del: bad code -- https://master.php.net/note/delete/124348/bad+code Del: spam -- https://master.php.net/note/delete/124348/spam Del: non-english -- https://master.php.net/note/delete/124348/non-english Del: in docs -- https://master.php.net/note/delete/124348/in+docs Del: other reasons-- https://master.php.net/note/delete/124348 Reject -- https://master.php.net/note/reject/124348 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#212864) next »