0
我有出現的聲音,但是當一個變量是空庫MySQLi bind_param UPDATE不是空值工作
$stmtEmploymentDetails = getDB()->prepare(
'UPDATE EmploymentDetails SET BranchOffice=?, EmploymentDate=?, EmploymentStatus=?, EmploymentType=?, OrdinaryHours=?, JobClassification=?, ManagmentGroupID=? WHERE EmployeeID=?'
);
,並結合PARAM不會更新表下面的MySQL查詢
$stmtEmploymentDetails->bind_param(
'ssiiisss',
$branchOffice,
$employmentDate,
$employmentStatus,
$employmentType,
$ordinaryHours,
$jobClassification,
$managmentGroupID,
$employeeID
);
$stmtEmploymentDetails->execute;
我有也嘗試使用COALESCE
但值(我假設)爲空不爲空
$stmtEmploymentDetails = getDB()->prepare(
'UPDATE EmploymentDetails SET BranchOffice=COALESCE(BranchOffice=?, BranchOffice), EmploymentDate=COALESCE(EmploymentDate=?, EmploymentDate), EmploymentStatus=COALESCE(EmploymentStatus=?, EmploymentStatus), EmploymentType=COALESCE(EmploymentType=?, EmploymentType), OrdinaryHours=COALESCE(OrdinaryHours=?, OrdinaryHours), JobClassification=COALESCE(JobClassification=?, JobClassification), ManagmentGroupID=COALESCE(ManagmentGroupID=?, ManagmentGroupID) WHERE EmployeeID=?'
);
同樣的方法不工作在一個較小的查詢任何問題
$stmtEmployeeProfile = getDB()->prepare(
'UPDATE EmployeeProfiles SET AKAName=? WHERE EmployeeID=?'
);
和
$stmtEmployeeProfile->bind_param(
'ss',
$AKAName,
$employeeID
);
$stmtEmployeeProfile->execute();
但在查詢中的值總是提供。 任何人都知道問題在哪裏?
如果可能,你可以顯示出現的錯誤? –
剛剛更新了問題以澄清問題。它將在沒有警告的情況下執行,但不會更新表格。我會考慮添加一些與「不適用」相關的內容,看看是否能解決問題。 –
如果您沒有默認值,它會一直抱怨,只要確保您在每種情況下都有正確的檢查,例如空,空,流行或不正確的值 –