/** * callback 驗證Email是否重複 */ public function cbValidateEmailUnique(sfValidatorCallback $Validator, $Value, $Arguments) { $Value = strtolower($Value); if (MemberTable::getInstance()->findOneByEmail($Value)) { throw new sfValidatorError($Validator, 'invalid', array('value' => $Value)); } return $Value; }
public function executeAuthenticateLogin(sfWebRequest $request) { $username = $request->getParameter('username'); $password = $request->getParameter('password'); $query = MemberTable::getInstance()->createQuery()->select('m.username, m.country')->from('Member m')->where('m.username = ?', $username)->andWhere('m.password = ?', $password); $rs = $query->fetchOne(); $rsCount = $query->execute()->count(); if ($rsCount > 0) { $_SESSION['username'] = $rs->getUsername(); $_SESSION['userId'] = $rs->getId(); $_SESSION['country'] = $rs->getCountry(); $_SESSION['state'] = $rs->getState(); } die(json_encode(array('success' => $rsCount == 0 ? false : true))); }
public static function checkMemberInfo($column = null, $value = null) { $q = MemberTable::getInstance()->createQuery(); $q->where("{$column} = ?", $value); return $q->execute(); }