/**
  * @since 2.5
  *
  * @param string $tableName
  */
 public function drop($tableName)
 {
     $sql = "DROP TEMPORARY TABLE " . $tableName;
     if ($this->withAutoCommit) {
         $this->connection->queryWithAutoCommit($sql, __METHOD__);
     } else {
         $this->connection->query($sql, __METHOD__);
     }
 }
 /**
  * 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()
 {
     if ($this->queryMode === Query::MODE_DEBUG) {
         return;
     }
     foreach ($this->executedQueries as $table => $log) {
         $this->connection->query("DROP TEMPORARY TABLE " . $this->connection->tableName($table), __METHOD__);
     }
 }
 /**
  * @since 2.3
  *
  * @param string $type
  * @param string $tablename
  * @param string $valueComposite
  *
  * @throws RuntimeException
  */
 public function createHierarchyTempTableFor($type, $tablename, $valueComposite)
 {
     list($smwtable, $depth) = $this->getHierarchyTableDefinitionForType($type);
     if (array_key_exists($valueComposite, $this->hierarchyCache)) {
         // Just copy known result.
         $this->connection->query("INSERT INTO {$tablename} (id) SELECT id" . ' FROM ' . $this->hierarchyCache[$valueComposite], __METHOD__);
         return;
     }
     $this->buildTempTableFor($tablename, $valueComposite, $smwtable, $depth);
 }
 public function testQueryThrowsException()
 {
     $database = $this->getMockBuilder('\\DatabaseBase')->disableOriginalConstructor()->setMethods(array('query'))->getMockForAbstractClass();
     $databaseException = new \DBError($database, 'foo');
     $database->expects($this->any())->method('query')->will($this->throwException($databaseException));
     $connectionProvider = $this->getMockBuilder('\\SMW\\DBConnectionProvider')->disableOriginalConstructor()->getMock();
     $connectionProvider->expects($this->atLeastOnce())->method('getConnection')->will($this->returnValue($database));
     $instance = new Database($connectionProvider);
     $this->setExpectedException('RuntimeException');
     $this->assertInstanceOf('ResultWrapper', $instance->query('Foo', __METHOD__));
 }
 /**
  * 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->connection->query("DROP TEMPORARY TABLE " . $this->connection->tableName($table), __METHOD__);
     }
 }