我有下面的功能,告诉数据库天气更新或插入取决于是否找到电子邮件地址这工作正常但是我仍然有一些$POST
信息需要进入另一个表,具体取决于id
我已经解决了,对于该if($emailCheck != FALSE)
语句,我可以运行另一个insert
语句并id
在其中设置
我的问题是我如何才能为声明insert
中的新信息实现这一目标else
?
插入功能:
function Insert()
{
$emailCheck = $this->checkEmail($email);
if($emailCheck != FALSE)
{
updateQuery by $emailCheck['id'])); // The email address is found so we update the data
}else{
Jojo::insertQuery; // The email address is not found so we insert the new row
}
}
检查功能:
function checkEmail($email)
{
$email = $POST['Email'];
if($email)
{
$candemail = selectRow("SELECT * FROM {table} WHERE email=?",$email);
if(isset($candemail['email']))
{
return $candemail;
} else {
return FALSE;
}
}
}
全功能:
function candidateInsert($fields, $candiatefilename,$jobid)
{
$emailCheck = Jojo_Plugin_name_jobs_apply::checkCandidateEmail($email);
if($emailCheck != FALSE)
{
//Jojo::updateQuery("UPDATE {db} SET first_name=?,last_name=?,home_phone=?,work_phone=?,mobile_phone=?,email=?,skype=?,contact_method=?,location=?,location_other=?,cv_path=? WHERE id=?", array($fields['FirstName'],$fields['LastName'],$fields['HomePhone'],$fields['WorkPhone'],$fields['MobilePhone'],$fields['Email'],$fields['Skype'],$fields['ContactMethod'],$fields['Location'],$fields['LocationOther'],$candiatefilename, $emailCheck['id']));
//Jojo::insertQuery("INSERT INTO {refocus_candidate_job} SET candidateID=?,jobID=?,appliedDate=?", array($emailCheck['id'],$jobid,date("d/m/y")));
}else{
Jojo::insertQuery("INSERT INTO {db} SET first_name=?,last_name=?,home_phone=?,work_phone=?,mobile_phone=?,email=?,skype=?,contact_method=?,location=?,location_other=?,cv_path=?", array($fields['FirstName'],$fields['LastName'],$fields['HomePhone'],$fields['WorkPhone'],$fields['MobilePhone'],$fields['Email'],$fields['Skype'],$fields['ContactMethod'],$fields['Location'],$fields['LocationOther'],$candiatefilename));
$id = Jojo::insertQuery;
//Jojo::insertQuery("INSERT INTO {db_candidate_job} SET candidateID=?,jobID=?,appliedDate=?", array($id,$jobid,date("d/m/y")));
}
}