/** * Implementation of printf() behavior for constructor. */ private function construct($format, $argv) { $this->con = SqlQuery::mysql_connect(); // Apply mysql_real_escape_string() on all format args foreach ($argv as &$arg) { $arg = mysql_real_escape_string($arg, $this->con); } $this->query_string = vsprintf($format, $argv); $this->result = SqlQuery::mysql_query($this->query_string, $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); }