public function testDropWithAutoCommit()
 {
     $this->connection->expects($this->once())->method('queryWithAutoCommit');
     $instance = new TemporaryTableBuilder($this->connection);
     $instance->WithAutoCommit(true);
     $instance->drop('Foo');
 }
 /**
  * @note we use two helper tables. One holds the results of each new iteration, one holds the
  * results of the previous iteration. One could of course do with only the above result table,
  * but then every iteration would use all elements of this table, while only the new ones
  * obtained in the previous step are relevant. So this is a performance measure.
  */
 private function buildTempTableFor($tablename, $values, $smwtable, $depth)
 {
     $db = $this->connection;
     $tmpnew = 'smw_new';
     $tmpres = 'smw_res';
     $this->temporaryTableBuilder->create($tmpnew);
     $this->temporaryTableBuilder->create($tmpres);
     // Adding multiple values for the same column in sqlite is not supported
     foreach (explode(',', $values) as $value) {
         $db->query("INSERT " . "IGNORE" . " INTO {$tablename} (id) VALUES {$value}", __METHOD__);
         $db->query("INSERT " . "IGNORE" . " INTO {$tmpnew} (id) VALUES {$value}", __METHOD__);
     }
     for ($i = 0; $i < $depth; $i++) {
         $db->query("INSERT " . 'IGNORE ' . "INTO {$tmpres} (id) SELECT s_id" . '@INT' . " FROM {$smwtable}, {$tmpnew} WHERE o_id=id", __METHOD__);
         if ($db->affectedRows() == 0) {
             // no change, exit loop
             break;
         }
         $db->query("INSERT " . 'IGNORE ' . "INTO {$tablename} (id) SELECT {$tmpres}.id FROM {$tmpres}", __METHOD__);
         if ($db->affectedRows() == 0) {
             // no change, exit loop
             break;
         }
         // empty "new" table
         $db->query('TRUNCATE TABLE ' . $tmpnew, __METHOD__);
         $tmpname = $tmpnew;
         $tmpnew = $tmpres;
         $tmpres = $tmpname;
     }
     $this->hierarchyCache[$values] = $tablename;
     $this->temporaryTableBuilder->drop($tmpnew);
     $this->temporaryTableBuilder->drop($tmpres);
 }
 /**
  * After querying, make sure no temporary database tables are left.
  * @todo I might be better to keep the tables and possibly reuse them later
  * on. Being temporary, the tables will vanish with the session anyway.
  */
 public function cleanUp()
 {
     foreach ($this->executedQueries as $table => $log) {
         $this->temporaryTableBuilder->drop($this->connection->tableName($table));
     }
 }
 private function newTemporaryTableBuilder()
 {
     $temporaryTableBuilder = new TemporaryTableBuilder($this->store->getConnection('mw.db.queryengine'));
     $temporaryTableBuilder->withAutoCommit($this->applicationFactory->getSettings()->get('smwgQTemporaryTablesAutoCommitMode'));
     return $temporaryTableBuilder;
 }