|
Server IP : 10.111.40.2 / Your IP : 216.73.217.145 Web Server : Apache System : Linux webd002.cluster111.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : comimage ( 586) PHP Version : 7.4.33 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/comimage/../comimage/arti/../taxiplus22.fr/archives/classes/ |
| [ Home ] | [ C0mmand ] | [ Upload File ] |
|---|
<?php
require 'MySQLException.php';
require 'MySQLResultSet.php';
require 'MySQLQuery.php';
////////////////////////////////////////////////////////////////////
class MySQLConnect{
//data members
private $connection;
private static $instances = 0;
const ONLY_ONE_INSTANCE_ALLOWED = 5000;
////////////////////////////////////////////////////////////////////
//constructor
////////////////////////////////////////////////////////////////////
public function __construct($hostname, $username, $password){
if(MySQLConnect::$instances == 0){
if(!$this->connection = mysql_connect($hostname, $username, $password )){
throw new MySQLException(mysql_error(), mysql_errno());
}
MySQLConnect::$instances = 1;
}else{
$msg = "Close the existing instance of the ".
"MySQLConnect class.";
throw new MySQLException($msg, self::ONLY_ONE_INSTANCE_ALLOWED);
}
}
////////////////////////////////////////////////////////////////////
//destructor
////////////////////////////////////////////////////////////////////
public function __destruct(){
$this->close();
}
////////////////////////////////////////////////////////////////////
//public methods
////////////////////////////////////////////////////////////////////
public function createResultSet($strSQL, $databasename){
$rs = new MySQLResultSet($strSQL, $databasename, $this->connection );
return $rs;
}
////////////////////////////////////////////////////////////////////
public function createQuery($strSQL, $databasename){
$rs = new MySQLQuery($strSQL, $databasename, $this->connection );
return $rs;
}
////////////////////////////////////////////////////////////////////
public function getConnection(){
return $this->connection;
}
////////////////////////////////////////////////////////////////////
public function getVersionNumber(){
//mysql_get_server_info
return mysql_get_server_info();
}
////////////////////////////////////////////////////////////////////
public function getInsertId(){
return mysql_insert_id($this->connection);
}
////////////////////////////////////////////////////////////////////
public function close(){
MySQLConnect::$instances = 0;
if(isset($this->connection)){
mysql_close($this->connection);
unset($this->connection);
}
}
}//end class
////////////////////////////////////////////////////////////////////
?>
