class Application_Model_DbTable_Email extends Zend_Db_Table_Abstract
{
protected $_name = 'memberdetail';
public function sendEmail($email)
{
$email = $_POST['email'];
$userid = ($this->select('userid')
->from('usertable', 'memberdetail')
->where('usertable.userid = memberdetail.memberid AND memberdetail.memberid = (SELECT memberid FROM memberdetail WHERE email = ?)', "".$email. "'"));
$reset = new Application_Model_DbTable_Register();
$reset->resetPass($userid);
$pswd = new Application_Model_DbTable_Register();
$pswd = $pswd->getTemp();
$mail = new Zend_Mail();
$mail->setFrom('swap.test@yahoo.com.sg', 'Inexorable Beauty');
$mail->addTo($email, $email);
$mail->setSubject('Inexorable Beauty: Password Reset');
$mail->setBodyText('Dear Customer,
You have requested to reset your password.
This is the temporary password: '.$pswd.'
Please log in immediately and change your password.
Thank You.
Yours Sincerely,
Inexorable Beauty');
$mail->send();
if($mail->send())
{
echo "Email successfully sent!";
}
else
{
echo "Email was not sent";
}
}
我正在尝试获取从memberid引用的用户标识。我可以通过我做过$ _POST ['email']的电子邮件获得memberid。问题是,我似乎无法获得用户ID的价值。我试图通过while循环回显用户ID,但它不起作用。当我打印SQL时,它似乎与我所写的不同。
答案 0 :(得分:1)
尝试运行这样的查询:
$email = $_POST['email'];
$subquery = $db->select()
->from('memberdetail', array('memberid'))
->where('email = ?', $email);
$select = $db->select()
->from('usertable', array('userid'))
->join('memberdetail', 'usertable.userid = memberdetail.memberid')
->where('usertable.userid = ?', $subquery);
$result = $select->query()->fetch();
if (!$result) {
// user not found
} else {
$userid = $result['userid'];
}
现在的方式,$userid
只是一个Zend_Db_Select
对象,但是没有执行任何查询。另外,您不会将任何参数传递给select()
,请在from()
方法中指定所需的列。