/** * Creates a new table based on the resource object. Returns table object * if successful * @param \Database\DB $db * @return \Database\Table */ public function createTable(\Database\DB $db) { $resource_table = $db->buildTable($this->getTable()); $datatypes = $this->getVariablesAsDatatypes($resource_table); if (!$datatypes) { throw new \Exception('Resource did not return any datatypes'); } $resource_table->addPrimaryIndexId(); $resource_table->create(); return $resource_table; }