Skip to content

Commit 1304a6e

Browse files
authored
fixed reset bug
1 parent c23581e commit 1304a6e

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

system/plugins/Database.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,9 @@ private function run()
470470
*/
471471
public function row($fetch = 'object')
472472
{
473+
// Reset
474+
$this->reset();
475+
473476
// Run Query
474477
$query = $this->pdo->query($this->sql);
475478

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

483-
// Reset
484-
$this->reset();
485-
486486
return $row;
487487
}
488488
catch(\PDOException $e)
@@ -498,6 +498,9 @@ public function row($fetch = 'object')
498498
*/
499499
public function results($fetch = 'object')
500500
{
501+
// Reset
502+
$this->reset();
503+
501504
// Run Query
502505
$query = $this->pdo->query($this->sql);
503506

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

515-
// Reset
516-
$this->reset();
517-
518518
return $result;
519519
}
520520
catch(\PDOException $e)
@@ -588,6 +588,9 @@ public function insert($table, $data = [])
588588

589589
try
590590
{
591+
// Reset
592+
$this->reset();
593+
591594
$query = $this->pdo->prepare($this->sql);
592595
$insert = $query->execute($val);
593596
$this->insert_id = $this->pdo->lastInsertId();
@@ -641,11 +644,11 @@ public function update($table, $data = [])
641644

642645
try
643646
{
644-
$query = $this->pdo->prepare($this->sql);
645-
$update = $query->execute($val);
646-
647647
// Reset
648648
$this->reset();
649+
650+
$query = $this->pdo->prepare($this->sql);
651+
$update = $query->execute($val);
649652

650653
return $update;
651654
}
@@ -684,12 +687,12 @@ public function delete($table)
684687

685688
try
686689
{
687-
$query = $this->pdo->prepare($this->sql);
688-
$delete = $query->execute($val);
689-
690690
// Reset
691691
$this->reset();
692692

693+
$query = $this->pdo->prepare($this->sql);
694+
$delete = $query->execute($val);
695+
693696
return $delete;
694697
}
695698
catch(\PDOException $e)
@@ -749,7 +752,6 @@ private function reset()
749752
$this->join = [];
750753
$this->order_by = [];
751754
$this->having = [];
752-
$this->insert_id = null;
753755
$this->error = null;
754756
$this->from = null;
755757
$this->group_by = null;

0 commit comments

Comments
 (0)