Skip to content

Commit

Permalink
fixed find not returning correct instance
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Sep 15, 2017
1 parent d59fb16 commit 64fa919
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ public function getColumnName()
public function createInsertQuery()
{
$this->makeDatabaseConnection();
$newkey = '';
foreach ($this->getClassCreateVariables() as $key => $value) {

$newkey .= " :".$key;
Expand Down Expand Up @@ -853,11 +854,10 @@ public function find($value)
} else {
$result = $this->get($value);
}

$new_instance = new $this;

$new_instance->update = true;
if ($result && count($result)) {
$new_instance = new $this;

if ($result->id) {
foreach ($result as $key => $value) {

if (!is_numeric($key)) {
Expand All @@ -866,6 +866,10 @@ public function find($value)
}

unset ($new_instance->last_query);

$new_instance->update = true;

$new_instance;
return $new_instance;
}

Expand Down

0 comments on commit 64fa919

Please sign in to comment.