此时,我正在尝试修改这个删除表行的插件,以仅删除“Status”列中不包含“Cekanje”一词的行,这是我尝试构建的代码和解决方案,如果有人可以帮助我:
$tableId = (int)$_POST[\'table_id\'];
$idKey = sanitize_text_field($_POST[\'id_key\']);
$idVal = (int)$_POST[\'id_val\'];
$wpdb->delete($mySqlTableName, array($idKey => $idVal));
$columnsMeta = WDTConfigController::loadColumnsFromDB($tableId, array($idColName));
if (count($columnsMeta) == 0) {
$returnResult[\'error\'] = __(\'Supplied id column not exist.\', \'wpdatatables\');
echo json_encode($returnResult);
exit();
} else {
$columnMeta = $columnsMeta[0];
if ($columnMeta->id_column) {
$idColumnKey = sanitize_text_field($columnMeta->orig_header);
$deleteRowIds = $rows[$idColumnKey];
foreach ($deleteRowIds as $rowId) {
$rowId = (int)$rowId;
if (empty($rowId)) {
continue;
}
do_action(\'wpdatatables_excel_before_delete_row\', $rowId, $tableId);
$res = $wpdb->delete($mySqlTableName, array($idColumnKey => $rowId));
这就是我正在尝试的解决方案,以防止删除“Status”=“Cekanje”的行
$dontdelete = $wpdb -> get_row($wpdb->prepare("SELECT id FROM SaveContactForm7_1 WHERE id != $idKey"));
if($dontdelete)
{
exit();
}