Skip to content

Commit

Permalink
dbCreate() now checks if table already exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
arnemorken committed Dec 13, 2023
1 parent ace7032 commit c656e1e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion data/mysql/db/dbTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ public function dbCreate($type,$tableFields,$unique)
if (!$type)
return false;
$tableName = "any_".$type;
if ($this->tableExists($tableName)) {
$this->mError = "dbTable::dbCreate: Table $tableName already exists";
error_log($this->mError);
return false;
}
$key_field = $type."_id"; // Default PRIMARY KEY field
$sql = "CREATE TABLE $tableName (";
if (!$tableFields) {
Expand All @@ -165,7 +170,8 @@ public function dbCreate($type,$tableFields,$unique)
error_log("Table $tableName created successfully");
return true;
}
error_log("Error creating table $tableName:".$this->getError());
$this->mError = "dbTable::dbCreate: Error creating table $tableName:".$this->getError();
error_log($this->mError);
return false;
} // dbCreate

Expand Down

0 comments on commit c656e1e

Please sign in to comment.