Skip to content

Commit

Permalink
Added responses to root methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Sven Marc Gehring committed May 21, 2014
1 parent 6fbda44 commit 2fe2162
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/crunchroot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function create($tablename){
if(strlen($tablename) < 2) throw new Exception('crunchDB: Table name is too short');
if(file_exists($table)) throw new Exception('crunchDB: Table "'.$tablename.'" already exists');
else file_put_contents($table, '[]');
return true;
}

/**
Expand All @@ -46,6 +47,7 @@ public function drop($tablename){
$table = $this->getFile($tablename);
if(!file_exists($table)) throw new Exception('crunchDB: Table "'.$tablename.'" doesn\'t exists');
else unlink($table);
return true;
}

/**
Expand All @@ -59,6 +61,7 @@ public function alter($tablename, $newname){
if(!file_exists($otable)) throw new Exception('crunchDB: Table "'.$tablename.'" doesn\'t exists');
if(file_exists($ntable)) throw new Exception('crunchDB: Table "'.$tablename.'" already exists');
rename($otable, $ntable);
return true;
}

/**
Expand All @@ -69,6 +72,7 @@ public function truncate($tablename){
$table = $this->getFile($tablename);
if(!file_exists($table)) throw new Exception('crunchDB: Table "'.$tablename.'" doesn\'t exists');
else file_put_contents($table, '[]');
return true;
}

public function tables(){
Expand Down

0 comments on commit 2fe2162

Please sign in to comment.