我有這個ajax請求,遍歷存儲並刪除所有選定的記錄。從商店刪除記錄與複選框選擇
代碼
Ext.Ajax.request({
url: 'system/index.php',
method: 'POST',
params: {
class: 'LicenseFeatures',
method: 'delete',
data: Ext.encode({
feature_id: (function(){
var e = "";
var sel = Ext.getCmp('featureGrid').getSelection();
var c = 0;
for(var i in sel) {
var x = (c == 0) ? e = sel[i].data.feature_id : e += "," + sel[i].data.feature_id;
c++;
}
return e;
})()
})
},
success: function(response){
Ext.MessageBox.alert('Status', 'Record(s) has been deleted.');
Ext.getStore('LicenseFeaturesStore').reload();
},
failure: function(){
Ext.MessageBox.alert('Status', 'Failed to delete records.');
}
});
目前的代碼從電網獲取1號並將其刪除。我需要做的是從網格中獲取兩個Id,因爲我需要將特定的sql運行到數據庫。 sql需要兩個輸入,這裏是sql
public function delete($vars){
$sql = "DELETE FROM `LicenseFeatures` WHERE feature_id in({$vars->data->feature_id}) AND license_id in({$vars->data->license_id})";
if($result = $vars->db->query($sql)) {
echo json_encode(array("success" => true,"sql"=>$sql));
} else {
echo json_encode(array("success" => false));
}
}
如果我沒有解釋清楚,請說出來 –
不太清楚你的意思。你在談論你在sql查詢中使用的license_id屬性嗎? – hansn
是的,我需要提交該屬性以及feature_id屬性 –