54
db.class.php
Normal file
54
db.class.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
class db
|
||||
{
|
||||
private $server = "localhost";
|
||||
private $port = 3306;
|
||||
private $user = "root";
|
||||
private $passwd = "DT_dedibox";
|
||||
public $dadabase;
|
||||
public $connect;
|
||||
public $result;
|
||||
|
||||
/*function __construct()
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
function open()
|
||||
{
|
||||
if ( ! $this->connect )
|
||||
{
|
||||
$this->connect = new mysqli( $this->server, $this->user, $this->passwd, $this->database );
|
||||
if ( $this->connect->connect_errno )
|
||||
{
|
||||
log_error( "Échec de la connexion : " . " => " . $this->connect->connect_error . "<br />" . __file__ . esp( 'ligne' ) . __line__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function close()
|
||||
{
|
||||
$this->connect->close();
|
||||
$this->connect = 0;
|
||||
}
|
||||
|
||||
function query( $string )
|
||||
{
|
||||
if ( empty( $this->connect ) ) $this->open();
|
||||
|
||||
$this->result = $this->connect->query( $string ) ;
|
||||
if ( $this->connect->error ) log_error( "Échec de la commande query" . " => ". $this->connect->error . "<br />" . __file__ . esp( 'ligne' ) . __line__ . "\n" . $string);
|
||||
}
|
||||
|
||||
function error()
|
||||
{
|
||||
print_r( $this );
|
||||
$this->error = $this->error;
|
||||
return $this->error;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user