나는 그들이 묻는 질문에 사용자를 연결시키는 CakePHP 1.3에 간단한 FAQ 시스템을 구축하고 있습니다.CakePHP 1.3 - 사용자 이메일 주소가 데이터베이스에 있는지 확인하고 있습니까?
동일한 사용자가 다른 사용자에게 질문 (로그인 또는 계정이 없음)을 묻는 경우 해당 사용자의 데이터베이스에 다른 항목을 만들고 싶지 않습니다 (이메일 주소 존재 여부에 따라 다름) 오히려 그 사용자 ID를 질문에 할당하십시오.
function add() {
if(!empty($this->data)) {
unset($this->Question->Visitor->validate['visitor_id']);
if ($this->Question->saveAll($this->data)) {
$this->Session->setFlash(__('The question has been saved', true));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The question could not be saved. Please, try again.', true));
}
}
}
를 다음과 같이 내 데이터베이스 구조는 다음과 같습니다 :
Questions
id
visitor_id
question
url
status_id
category_id
description
keywords
created
modified
Visitors
id
name
emailaddress
newsletter
ipaddress
created
modified
어떻게 이렇게 가겠어요 다음과 같이
내 추가() 함수는 현재?
감사합니다. $ this-> 데이터 [ '질문'] [ '이메일'] 적절 방문자에 대한
그것은 완벽하게 이해할 수 있습니다. 감사합니다. – Probocop
이메일 열 이름을 'email'로 지정하지 않았으므로 findByEmail 함수를 사용할 수 없었지만 다음과 같은 결과를 얻었습니다. http://pastie.org/1704598 – Probocop
그런 다음 findByEmailaddress()를 사용하십시오. 필드 이름을 추출하는 마법 방법! http://book.cakephp.org/view/1026/findBy – Leo