Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/components/record/record.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,11 @@ public function setKey(array $fields, $type, $name=null, $add=true) {
*
* @param string $table The name of the table to create
* @param boolean $if_not_exists If true will create the table IFF the table does not exist
* @param boolean $temp If true will create a temporary table that is destroyed once the database connection is ended
*/
public function create($table, $if_not_exists=false) {
public function create($table, $if_not_exists=false, $temp=false) {
$this->type = "create" . ($if_not_exists ? "_if_not_exists" : "");
$this->temp_table = $temp;
$this->tables[] = $table;

$this->query($this->buildQuery(), $this->values);
Expand Down Expand Up @@ -170,8 +172,10 @@ public function truncate($table) {
*
* @param string $table The name of the table to create
* @param boolean $if_exists If true will drop the table only if it exists
* @param boolean $temp If true denotes the table as a temporary one instead of permenant
*/
public function drop($table, $if_exists=false) {
public function drop($table, $if_exists=false, $temp=false) {
$this->temp_table = $temp;
$this->type = "drop" . ($if_exists ? "_if_exists" : "");
$this->tables[] = $table;

Expand Down Expand Up @@ -988,7 +992,7 @@ private function buildQuery() {
break;
case "create_if_not_exists":
case "create":
$sql = "CREATE TABLE " . ($this->type == "create_if_not_exists" ? "IF NOT EXISTS " : "") . $this->buildTables() . $this->buildFields() . $this->buildTableOptions();
$sql = "CREATE ". ($this->temp_table == true ? "TEMPORARY ": "") . "TABLE " . ($this->type == "create_if_not_exists" ? "IF NOT EXISTS " : "") . $this->buildTables() . $this->buildFields() . $this->buildTableOptions();
break;
case "alter":
$sql = "ALTER TABLE " . $this->buildTables() . $this->buildFields(false);
Expand All @@ -998,7 +1002,7 @@ private function buildQuery() {
break;
case "drop_if_exists":
case "drop":
$sql = "DROP TABLE " . ($this->type == "drop_if_exists" ? "IF EXISTS " : "") . $this->buildTables();
$sql = "DROP ". ($this->temp_table == true ? "TEMPORARY " : "") . "TABLE " . ($this->type == "drop_if_exists" ? "IF EXISTS " : "") . $this->buildTables();
break;
}
return $sql;
Expand Down