I am wondering if I use mysql with php secure. This is my class:
class DB{ public $mysqli = null; public $result = array(); private $_host = 'localhost'; private $_user = 'root'; private $_password = 'root'; private $_db_name = 'DBNAME'; public function __construct() { $this->mysqli = new mysqli($this->_host,$this->_user, $this->_password, $this->_db_name); if ($this->mysqli->connect_errno){ echo "Error MySQLi: (" . $this->mysqli->connect_errno . ") " . $this->mysqli->connect_error; exit(); } $this->mysqli->set_charset("utf8"); } public function __destruct(){ $this->mysqli->close(); } public function query($query){ $this->result = $this->mysqli->query($query); if($this->result){ return $this->result; }else{ return false; } } Is that way to comunicate with database good enough or should I use Doctrine ?
I am asking because something strange is in my code. If I vardump any object contains reference to DB object, I can see :
["_host":"DB":private]=> string(9) "localhost" ["_user":"DB":private]=> string(4) "root" ["_password":"DB":private]=> string(4) "root" ["_db_name":"DB":private]=> string(10) >"DBNAME" }