db->select(); $select->from($this->pair, array('id')); $select->where('email = ' . $this->db->quote($email)); $select->limit(1); if (false !== ($id = $this->db->fetchOne($select))) { $this->_primaryKey = $id; } return $this; } public function setPrimaryKeyByRecoverCode($recoverCode) { $select = $this->db->select(); $select->from($this->pair, array('id')); $select->where('recoverCode = ' . $this->db->quote($recoverCode)); $select->limit(1); if (false !== ($id = $this->db->fetchOne($select))) { $this->_primaryKey = $id; } return $this; } function setNewPassword($newPassword, $newSalt, $recoverCode, $expirationDate) { $updateData = array( 'newPassword' => $this->_encryptPass($newPassword, $newSalt), 'newSalt' => $newSalt, 'recoverCode' => $recoverCode, 'recoverCodeExpirationDate' => $expirationDate ); $this->table->updateByKey($updateData, $this->_primaryKey); } public function activatePassword($primaryKey = null) { if (null !== $primaryKey) { $this->setPrimaryKey($primaryKey); } $data = $this->getData(); $updateData = array( 'password' => $data['newPassword'], 'salt' => $data['newSalt'], 'newPassword' => null, 'newSalt' => null, 'recoverCode' => null, 'recoverCodeExpirationDate' => null ); return $this->table->updateByKey($updateData, $this->_primaryKey); } }