public function get_connection(){
try{
$this->connection = @mysqli_connect( $this->databaselink, $this->username, $this->password );
if( $this->connection === false ){
throw new Exception( mysql_error() );
}
if( !mysqli_select_db($this->connection, $this->database) ){
echo "no db selected error";
throw new Exception( mysql_error() );
}
}
catch(Exception $e){
echo $e->getMessage();
//$this->log->logger( "MYSQL", $e, $query );
}
}
public function close_connection(){
mysqli_close( $this->connection );
$this->connection = NULL;
}
public function query( $query ){
$this->get_connection();
try {
if( empty($query) ){
throw new Exception($query . " query empty");
}
$this->result = @mysqli_query($this->connection, $query);
if( !$this->result ){
throw new Exception( mysqli_error($this->connection) );
} else {
return $this->result;
}
} catch(Exception $e){
echo $e->getMessage();
//$this->log->logger( "MYSQL", $e, $query );
}
echo mysqli_info($this->connection);
// $this->close_connection();
}
public function last_insert_id(){
// $this->get_connection();
return mysqli_insert_id($this->connection);
// $this->close_connection();
}
}
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE