Skip to content

Commit

Permalink
fix for php 7+
Browse files Browse the repository at this point in the history
fix issue #2
improve indentation
  • Loading branch information
Kurairaito authored Aug 12, 2018
1 parent 366699f commit 5fc1be6
Showing 1 changed file with 37 additions and 29 deletions.
66 changes: 37 additions & 29 deletions mysql.sessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,34 @@ public function __construct(){

// Set handler to overide SESSION
session_set_save_handler(
array($this, "_open"),
array($this, "_close"),
array($this, "_read"),
array($this, "_write"),
array($this, "_destroy"),
array($this, "_gc")
array($this, "_open"),
array($this, "_close"),
array($this, "_read"),
array($this, "_write"),
array($this, "_destroy"),
array($this, "_gc")
);

// Start the session
session_start();
}
public function _open(){
// If successful
if($this->db){
// Return True
return true;
if($this->db)
{
// Return True
return true;
}
// Return False
return false;
}
public function _close(){
// Close the database connection
// If successful
if($this->db->close()){
// Return True
return true;
if($this->db->close())
{
// Return True
return true;
}
// Return False
return false;
Expand All @@ -71,15 +73,18 @@ public function _read($id){
$this->db->bind(':id', $id);
// Attempt execution
// If successful
if($this->db->execute()){
// Save returned row
$row = $this->db->single();
// Return the data
return $row['data'];
}else{
if($this->db->execute())
{
if($this->db->rowCount() > 0)
{
// Save returned row
$row = $this->db->single();
// Return the data
return $row['data'];
}
}
// Return an empty string
return '';
}
}
public function _write($id, $data){
// Create time stamp
Expand All @@ -92,9 +97,10 @@ public function _write($id, $data){
$this->db->bind(':data', $data);
// Attempt Execution
// If successful
if($this->db->execute()){
// Return True
return true;
if($this->db->execute())
{
// Return True
return true;
}
// Return False
return false;
Expand All @@ -106,9 +112,10 @@ public function _destroy($id){
$this->db->bind(':id', $id);
// Attempt execution
// If successful
if($this->db->execute()){
// Return True
return true;
if($this->db->execute())
{
// Return True
return true;
}
// Return False
return false;
Expand All @@ -121,12 +128,13 @@ public function _gc($max){
// Bind data
$this->db->bind(':old', $old);
// Attempt execution
if($this->db->execute()){
// Return True
return true;
if($this->db->execute())
{
// Return True
return true;
}
// Return False
return false;
}
}
?>
?>

0 comments on commit 5fc1be6

Please sign in to comment.