protected function tearDown() { //restore presence_users table state //remove possible tester users $sql = "DELETE \n FROM presence_users \n WHERE id = ? OR id = ? OR id = ? LIMIT 1"; DB::runSQL($sql, array('999999', '999998', '999997')); }
private function clean_old_tokens() { $tokens = AuthModel::find_all(); $to_remove = array(); foreach ($tokens as $token) { if ($token->timeexpires < time()) { $to_remove[] = $token->id; } } $sql = "DELETE FROM presence_auth\n\t\tWHERE id IN(" . implode(',', $to_remove) . ")"; DB::runSQL($sql, array()); }
`y` int(11) NOT NULL, `m` int(11) NOT NULL, `d` int(11) NOT NULL, `h` int(11) NOT NULL, `i` int(11) NOT NULL, `s` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;'; echo 'Creating the table <b>presence_intervals</b></br>'; DB::runSQL($presence_intervals_table_sql, array()); //presence_users $presence_users_table_sql = ' USE ' . $CONFIG->dbname . '; CREATE TABLE IF NOT EXISTS `presence_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `identifier` varchar(150) COLLATE utf8_bin NOT NULL, `password` char(40) COLLATE utf8_bin NOT NULL, `role` varchar(20) COLLATE utf8_bin NOT NULL, `firstname` varchar(200) COLLATE utf8_bin NOT NULL, `lastname` varchar(300) COLLATE utf8_bin NOT NULL, `position` varchar(200) COLLATE utf8_bin NOT NULL, `UUID` char(40) COLLATE utf8_bin NOT NULL, `mac` char(40) COLLATE utf8_bin NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=1 ;'; echo 'Creating the table <b>presence_users</b></br>'; DB::runSQL($presence_users_table_sql, array()); echo 'Done creating the database!</br>'; ?> </body> </html>
public static function mark_as_computed($entries) { $sql = "UPDATE " . self::table() . "\n\t\t\t\tSET computed = ?\n\t\t\t\tWHERE id IN(" . implode(',', $entries) . ")"; return DB::runSQL($sql, array('1')); }