Beta
This commit is contained in:
parent
87ab2e249c
commit
bacb59dd66
|
@ -10,6 +10,11 @@ class Conn
|
|||
private $conn = NULL;
|
||||
private $isOpen = FALSE;
|
||||
|
||||
function __construct ()
|
||||
{
|
||||
$this->initHandler ();
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens a new connection to the database.
|
||||
*
|
||||
|
@ -22,7 +27,7 @@ class Conn
|
|||
**/
|
||||
function open ($host, $user, $pass, $name, $port = NULL)
|
||||
{
|
||||
$conn = $this->conn = mysqli_init ();
|
||||
$conn = $this->initHandler ();
|
||||
$conn->options (MYSQLI_OPT_LOCAL_INFILE, TRUE);
|
||||
$conn->options (MYSQLI_READ_DEFAULT_FILE, __DIR__.'/my.cnf');
|
||||
$conn->real_connect ($host, $user, $pass, $name, $port);
|
||||
|
@ -45,11 +50,39 @@ class Conn
|
|||
function close ()
|
||||
{
|
||||
if ($this->isOpen)
|
||||
{
|
||||
$this->conn->close ();
|
||||
|
||||
$this->conn = NULL;
|
||||
}
|
||||
|
||||
$this->isOpen = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the internal database connection handler.
|
||||
*
|
||||
* @return Objetct The connection handler
|
||||
**/
|
||||
function initHandler ()
|
||||
{
|
||||
if (!$this->conn)
|
||||
$this->conn = new \mysqli ();
|
||||
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the internal database connection handler. This function shoud be
|
||||
* used to set options for specific databases that could not be set using
|
||||
* the Db\Conn class methods.
|
||||
*
|
||||
* @return Objetct The connection handler
|
||||
**/
|
||||
function getHandler ()
|
||||
{
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the default schema for the current connection.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue