當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DboSource::hasResult方法代碼示例

本文整理匯總了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;
 }
開發者ID:alescx,項目名稱:forum,代碼行數:51,代碼來源:InstallShell.php


注:本文中的DboSource::hasResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。