我有以下if statement
,對於一個insert
工作正常,但我似乎無法得到它僅更新與項目表中未插入:PHP MYSQL配置更新語句
插入:
for($i=0; $i<count($fields['Occupation']); $i++) {
$id = $fields['Occupation'][$i];
CMS::insertQuery("INSERT INTO {table} SET canid=?, categoryid=?", array($emailCheck['id'], $id));
}
echo 'found update';
我都試過,沒有運氣以下更新線。
CMS::updateQuery("UPDATE {refocus_candidate_category} SET canid=?, categoryid=? WHERE canid=? AND categoryid=?", array($emailCheck['id'], $id));
聲明全文:
$catParams = array_merge(array($emailCheck['id']), $fields['Occupation']);
$catPlaceholders = '?'.str_repeat(',?',count($fields['Occupation'])-1);
$catCheck = CMS::selectQuery("SELECT * FROM {table} WHERE canid=? AND categoryid IN (".$catPlaceholders.")", $catParams);
if($catCheck != FALSE)
{
for($i=0; $i<count($fields['Occupation']); $i++) {
$id = $fields['Occupation'][$i];
CMS::updateQuery("UPDATE {table} SET canid=?, categoryid=? WHERE canid=? AND categoryid=?", array($emailCheck['id'], $id));
}
echo 'found update'l
}else{
for($i=0; $i<count($fields['Occupation']); $i++) {
$id = $fields['Occupation'][$i];
CMS::insertQuery("INSERT INTO {table} SET canid=?, categoryid=?", array($emailCheck['id'], $id));
}
echo 'else insert';
}
後您嘗試進行更新的代碼,完整的一個 – rsz
您的更新查詢四個參數,但你只提供兩個值..? – heretolearn