/** * Destructor, meant to be automatically invoked as the SqlQuery * object goes out of scope. */ public function __destruct() { SqlQuery::mysql_close($this->con); }
/** * Removes all data from the database. Meant to be called before * each time we run automatic tests on the site so we get a * predictable test fixture. */ public static function purge_test_database() { $con = SqlQuery::mysql_connect(); $all_tables = array("Users", "LoginTokens", "Projects", "Tasks", "Sizes", "Names", "Remaining"); foreach ($all_tables as $table) { SqlQuery::mysql_query("DELETE FROM {$table}", $con); $affected_rows_count = mysql_affected_rows($con); echo "Deleted {$affected_rows_count} from {$table}\n"; } SqlQuery::mysql_close($con); }