本文整理匯總了PHP中DboSource::hasResult方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::hasResult方法的具體用法?PHP DboSource::hasResult怎麽用?PHP DboSource::hasResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DboSource
的用法示例。
在下文中一共展示了DboSource::hasResult方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _newUser
/**
* Gather all the data for creating a new user.
*
* @param string $mode
* @return string
*/
protected function _newUser($mode)
{
$userMap = Configure::read('Forum.userMap');
switch ($mode) {
case 'username':
$username = trim($this->in('<question>Username:</question>'));
if (!$username) {
$username = $this->_newUser($mode);
} else {
$result = $this->db->fetchRow(sprintf("SELECT COUNT(*) AS `count` FROM `%s` AS `User` WHERE `%s` = %s", $this->install['table'], $userMap['username'], $this->db->value($username)));
if ($this->db->hasResult() && $result[0]['count']) {
$this->out('<error>Username already exists, please try again</error>');
$username = $this->_newUser($mode);
}
}
return $username;
break;
case 'password':
$password = trim($this->in('<question>Password:</question>'));
if (!$password) {
$password = $this->_newUser($mode);
}
return $password;
break;
case 'email':
$email = trim($this->in('<question>Email:</question>'));
if (!$email) {
$email = $this->_newUser($mode);
} else {
if (!Validation::email($email)) {
$this->out('<error>Invalid email address, please try again</error>');
$email = $this->_newUser($mode);
} else {
$result = $this->db->fetchRow(sprintf("SELECT COUNT(*) AS `count` FROM `%s` AS `User` WHERE `%s` = %s", $this->install['table'], $userMap['email'], $this->db->value($email)));
if ($this->db->hasResult() && $result[0]['count']) {
$this->out('<error>Email already exists, please try again</error>');
$email = $this->_newUser($mode);
}
}
}
return $email;
break;
}
return null;
}