public static function find($username)
 {
     if (!self::$db) {
         self::$db = MySQL_Database::instance();
     }
     $username = preg_replace('/([%_])/', '\\\\\\1', $username);
     $find_sql = "SELECT * FROM " . MYSQL_PREFIX . "users\n            WHERE username LIKE :username LIMIT 1";
     $find = self::$db->prepare($find_sql);
     $find->execute(array(':username' => $username));
     $user = $find->fetch(PDO::FETCH_OBJ);
     return new User($user->username, $user->password, $user->user_id, $user->last_known_ip, $user->last_login);
 }
Exemple #2
0
 public static function find($username)
 {
     if (!self::$db) {
         self::$db = MySQL_Database::instance();
     }
     ### not sure what this is good for. as we use LIKE to find and LIMIT 1 to get only one record,
     ### why do we need to replace the jokers?
     $username = preg_replace('/([%_])/', '\\\\\\1', $username);
     $find_sql = 'SELECT * FROM ' . MYSQL_PREFIX . 'users WHERE username LIKE :username LIMIT 1';
     $find = self::$db->prepare($find_sql);
     $find->execute(array(':username' => $username));
     $user = $find->fetch(PDO::FETCH_OBJ);
     return new User($user->username, $user->password, $user->user_id, $user->last_known_ip, $user->last_login);
 }