Skip to content

Commit

Permalink
fixed all notice errors inside models
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmancuso committed Aug 13, 2017
1 parent 69fbb9e commit bbe9d1a
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public function __construct($default_database = null)
$this->database = $default_database;
}

$this->database_connected = false;

if (method_exists($this, 'create')) {
$this->create = true;
$this->createDatabaseIfNotExists();
Expand Down Expand Up @@ -75,7 +77,7 @@ public function createTable()
$keys = explode(":", $value);
$query_string .= " DATETIME NOT NULL";

if ($keys[1]) {
if (isset($keys[1])) {
$query_string .= " DEFAULT $keys[1]";
}
} elseif (preg_match('/^date/', $value)) {
Expand Down Expand Up @@ -167,9 +169,9 @@ private function updateForeignKey($tablecolumn, $key, $value)
$keys = explode(':', $value);
$table = $this->getTableName();
$create_columns = $this->getClassCreateVariables();
$drop_foreign_key .= "
$drop_foreign_key = "
ALTER TABLE $table DROP
FOREIGN KEY `$keys[1]"._."$keys[2]_fk`";
FOREIGN KEY `$keys[1]"."_"."$keys[2]_fk`";

if ($tablecolumn) {
$alter_column = "
Expand Down Expand Up @@ -239,6 +241,8 @@ private function getClassCreateVariables()
unset($allClassProperties['lastrow']);
unset($allClassProperties['update']);
unset($allClassProperties['last_query']);
unset($allClassProperties['structure']);
unset($defaultClassProperties['structure']);

return array_diff($allClassProperties, $defaultClassProperties);
}
Expand Down Expand Up @@ -530,7 +534,8 @@ public function getTableName()
return strtolower(end(explode("\\", static::class)));
}
} else {
return strtolower(end(explode("\\", static::class)));
$explode_namespace = explode("\\", static::class);
return strtolower(end($explode_namespace));
}
}

Expand Down Expand Up @@ -685,7 +690,7 @@ private function callEvent($event, $trigger)

public function triggerEvent($event)
{
if ($this->Events) {
if (isset($this->Events)) {
foreach($this->Events as $key => $value){
if ($key == $event) {
$this->callEvent($this->Events[$event], $key);
Expand Down Expand Up @@ -827,6 +832,7 @@ public function updateFromPost($post, $where_clause = 1)
{
$this->triggerEvent('updating');
$this->makeDatabaseConnection();
$values = "";
foreach ($post as $key => $value) {
$values .= "`".$key."` = '".$value."',";
}
Expand All @@ -835,7 +841,6 @@ public function updateFromPost($post, $where_clause = 1)
$val = rtrim($val, ",");

$table = $this->getTableName();

$query = $this->db_engine->query("UPDATE `$table` SET $val WHERE $where_clause LIMIT 1");
return $query;
}
Expand Down

0 comments on commit bbe9d1a

Please sign in to comment.