* Return a table instance
*/
public function table($name='',$params=[]) {
+ if ( !is_array($params) ) bye('[type=>, sql=>, ...]');
if (!$name and !empty($this->default_table)) $name = $this->default_table;
if (!$name) $this->bye('table(): Missing table');
$fields = array_keys($this->rows[0]);
$sql_names = $this->sql_names($fields);
- $this->db()->conn->query("CREATE TEMPORARY TABLE $this->name ("
+ $this->db()->conn->query("CREATE ".$this->sql_temporary()." TABLE $this->name ("
.join(',',$this->ar_map('"$a text"',$sql_names))
.')');
$sql = 'INSERT INTO '. $this->sql_name("$this->name")
return true;
}
+ private function sql_temporary() {
+ if ($this->type == 'sqlite') return 'TEMP';
+ return 'TEMPORARY';
+ }
+
/*
* Function create_temporary
*
// Name, could be a select
if (DB_TABLE_QUERY_NAME and stripos($this->name,'SELECT ')===0) {
- $this->db()->conn->query("CREATE TEMPORARY TABLE ".DB_TABLE_QUERY_NAME." AS $this->name");
+ $this->db()->conn->query("CREATE ".$this->sql_temporary()." TABLE ".DB_TABLE_QUERY_NAME." AS $this->name");
$this->name = DB_TABLE_QUERY_NAME;
// Virtual Table
} elseif (DB_TABLE_QUERY_NAME and !empty($this->sql)) {
# NB 29.12.16 table already exists !!! if ($this->name) $this->name = DB_TABLE_QUERY_NAME;
- $this->db()->conn->query("CREATE TEMPORARY TABLE $this->name AS $this->sql");
+ $this->db()->conn->query("CREATE ".$this->sql_temporary()." TABLE $this->name AS $this->sql");
} elseif (preg_match('/\b(\.import|LOAD DATA|COPY|INSERT|REPLACE|DELETE|TRUNCATE|CREATE|DROP|ALERT)\b/',$this->name)) {
bye("Query not Allowed !");