Example #1
0
 /**
  * {@inheritdoc}
  */
 public function deleteTable($table, $check_empty = false)
 {
     $name = is_array($table) ? ArrayUtils::get($table, 'name') : $table;
     if (empty($name)) {
         throw new BadRequestException('Table name can not be empty.');
     }
     try {
         $this->parent->getConnection()->useDatabase($name);
         $this->parent->getConnection()->asArray()->deleteDatabase();
         $this->refreshCachedTables();
         // $result['ok'] = true
         return ['name' => $name];
     } catch (\Exception $ex) {
         throw new InternalServerErrorException("Failed to delete table '{$name}'.\n{$ex->getMessage()}");
     }
 }
Example #2
0
 public function testDropTable()
 {
     $request = new TestServiceRequest(Verbs::DELETE);
     $rs = $this->service->handleRequest($request, Schema::RESOURCE_NAME . '/' . static::TABLE_NAME);
     $request->setMethod(Verbs::GET);
     $rs = $this->service->handleRequest($request, Schema::RESOURCE_NAME . '/' . static::TABLE_NAME);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 protected function rollbackTransaction()
 {
     if (!empty($this->rollbackRecords)) {
         switch ($this->getAction()) {
             case Verbs::POST:
                 $this->parent->getConnection()->asArray()->deleteDocs($this->rollbackRecords, true);
                 break;
             case Verbs::PUT:
             case Verbs::PATCH:
             case Verbs::MERGE:
             case Verbs::DELETE:
                 $this->parent->getConnection()->asArray()->storeDocs($this->rollbackRecords, true);
                 break;
             default:
                 // nothing to do here, rollback handled on bulk calls
                 break;
         }
         $this->rollbackRecords = [];
     }
     return true;
 }