Skip to content

Commit

Permalink
fixed reset bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tkaratug authored Mar 23, 2017
1 parent c23581e commit 1304a6e
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions system/plugins/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ private function run()
*/
public function row($fetch = 'object')
{
// Reset
$this->reset();

// Run Query
$query = $this->pdo->query($this->sql);

Expand All @@ -480,9 +483,6 @@ public function row($fetch = 'object')
else
$row = $query->fetch(\PDO::FETCH_OBJ);

// Reset
$this->reset();

return $row;
}
catch(\PDOException $e)
Expand All @@ -498,6 +498,9 @@ public function row($fetch = 'object')
*/
public function results($fetch = 'object')
{
// Reset
$this->reset();

// Run Query
$query = $this->pdo->query($this->sql);

Expand All @@ -512,9 +515,6 @@ public function results($fetch = 'object')
// Row Count
$this->num_rows = $query->rowCount();

// Reset
$this->reset();

return $result;
}
catch(\PDOException $e)
Expand Down Expand Up @@ -588,6 +588,9 @@ public function insert($table, $data = [])

try
{
// Reset
$this->reset();

$query = $this->pdo->prepare($this->sql);
$insert = $query->execute($val);
$this->insert_id = $this->pdo->lastInsertId();
Expand Down Expand Up @@ -641,11 +644,11 @@ public function update($table, $data = [])

try
{
$query = $this->pdo->prepare($this->sql);
$update = $query->execute($val);

// Reset
$this->reset();

$query = $this->pdo->prepare($this->sql);
$update = $query->execute($val);

return $update;
}
Expand Down Expand Up @@ -684,12 +687,12 @@ public function delete($table)

try
{
$query = $this->pdo->prepare($this->sql);
$delete = $query->execute($val);

// Reset
$this->reset();

$query = $this->pdo->prepare($this->sql);
$delete = $query->execute($val);

return $delete;
}
catch(\PDOException $e)
Expand Down Expand Up @@ -749,7 +752,6 @@ private function reset()
$this->join = [];
$this->order_by = [];
$this->having = [];
$this->insert_id = null;
$this->error = null;
$this->from = null;
$this->group_by = null;
Expand Down

0 comments on commit 1304a6e

Please sign in to comment.