public static function getByName($strName) { /* By putting the username into an object, it is sanitized. */ $objUser = new clsUser(); $objUser->set('username', $strName); $arrResults = clsDB::getListStatic('user', "`<<user><username>>`='" . $objUser->get('username') . "'"); if (sizeof($arrResults) == 0) { return null; } // Username wasn't found if (sizeof($arrResults) > 1) { throw new Exception("exception_multiplenames"); } /* should never happen, but who knows? */ return new clsUser($arrResults[0]->get('id')); }