id = $identifier; } else { $this->username = $identifier; } $this->db = $database; } /** * Checks whether username or e-mail already exists in the database. * * @param IDbConnection $db The current database connection. * @param string $value Value to check names and emails for. * @return boolean Returns true if the value exists in database, * false otherwise. */ public static function exists(IDbConnection $db, $value) { $sql = '( SELECT Count(*) AS Total FROM '.TB_PREFIX.'users WHERE username = ? OR email = ? ) UNION ALL ( SELECT Count(*) AS Total FROM '.TB_PREFIX.'activate WHERE username = ? OR email = ? )'; $res = $db->query_new($sql, $value, $value, $value, $value); return ($res[0]['Total'] > 0 || $res[1]['Total']); } }