I've been using this for a while updating mysql as needed. However I'm not too sure on the syntax..and need to migrate the sql to an array.
Particulary the line
database::query("CREATE TABLE $name($query)");
Does this translate to
CREATE TABLE bookmark(name VARCHAR(64), url VARCHAR(256), tag VARCHAR(256), id INT)
This is my ...guess. Is this correct?
class table extends database
{
private function create($name, $query)
{
database::query("CREATE TABLE $name($query)");
}
public function make($type)
{
switch ($type)
{
case "credentials":
self::create('credentials', 'id INT NOT NULL AUTO_INCREMENT, flname VARCHAR(60), email VARCHAR(32), pass VARCHAR(40), PRIMARY KEY(id)');
break;
case "booomark":
self::create('boomark', 'name VARCHAR(64), url VARCHAR(256), tag VARCHAR(256), id INT');
break;
case "tweet":
self::create('tweet', 'time INT, fname VARCHAR(32), message VARCHAR(128), email VARCHAR(64)');
break;
default:
throw new Exception('Invalid Table Type');
}
}
}