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 in_users FROM '.TB_PREFIX.'users WHERE username = ? OR email = ? ) UNION ALL ( SELECT Count(*) AS in_act FROM '.TB_PREFIX.'activate WHERE username = ? OR email = ? )'; $res = $db->query_new($sql, $value, $value, $value, $value); // convert result into an array $res = mysqli_fetch_array($res, MYSQLI_NUM); return ($res[0] > 0 || (count($res) > 1 && $res[1] > 0)); } }