/**
  * Given one correct xmldb_table, returns the SQL statements
  * to create temporary table (inside one array)
  */
 public function getCreateTempTableSQL($xmldb_table)
 {
     $this->temptables->add_temptable($xmldb_table->getName());
     $sqlarr = parent::getCreateTableSQL($xmldb_table);
     // we do not want the engine hack included in create table SQL
     $sqlarr = preg_replace('/^CREATE TABLE (.*)/s', 'CREATE TEMPORARY TABLE $1', $sqlarr);
     return $sqlarr;
 }
Exemplo n.º 2
0
 /**
  * Given one correct xmldb_table, returns the SQL statements
  * to create temporary table (inside one array).
  *
  * @param xmldb_table $xmldb_table The xmldb_table object instance.
  * @return array of sql statements
  */
 public function getCreateTempTableSQL($xmldb_table)
 {
     // Do we know collation?
     $collation = $this->mdb->get_dbcollation();
     $this->temptables->add_temptable($xmldb_table->getName());
     $sqlarr = parent::getCreateTableSQL($xmldb_table);
     // Let's inject the extra MySQL tweaks.
     foreach ($sqlarr as $i => $sql) {
         if (strpos($sql, 'CREATE TABLE ') === 0) {
             // We do not want the engine hack included in create table SQL.
             $sqlarr[$i] = preg_replace('/^CREATE TABLE (.*)/s', 'CREATE TEMPORARY TABLE $1', $sql);
             if ($collation) {
                 if (strpos($collation, 'utf8_') === 0) {
                     $sqlarr[$i] .= " DEFAULT CHARACTER SET utf8";
                 }
                 $sqlarr[$i] .= " DEFAULT COLLATE {$collation}";
             }
         }
     }
     return $sqlarr;
 }