Skip to content

Commit

Permalink
Added connect() and disconnect() in getKeys()
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonygauthier authored Apr 1, 2019
1 parent 5d8cff1 commit 30bcbf3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/MySimpleORM/Mapper/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public function select($table, $columns = null, $wheres = null, $joins = null, $
$return = array();

if ($table != "" || $table != null) {
echo "selecting!!\n";
//Open up connection
$this->connect();

Expand Down Expand Up @@ -372,11 +373,14 @@ public function update($table, $columns, $values, $wheres = null)

public function getKeys($table, $type = "primary")
{
$this->connect();

if ($type == "primary") {
$this->Sql = "SHOW COLUMNS FROM " . $table . ";";
$results = $this->Instance->query($this->Sql);
foreach ($results as $row) {
if ($row["Key"] == "PRI") {
$this->disconnect();
return $row["Field"];
}
}
Expand All @@ -398,7 +402,7 @@ public function getKeys($table, $type = "primary")
$return[] = array($column_name);
}
}

$this->disconnect();
return $return;
}
}
Expand Down

0 comments on commit 30bcbf3

Please sign in to comment.