无法获取 MySQL 更新查询以使用 jsgrid

Can't get MySQL Update query to work with jsgrid

我目前将此代码连接到 JSGrid table:

$connect = new PDO("mysql:host=localhost;dbname=localDatabase", "root", "root");

$method = $_SERVER['REQUEST_METHOD'];

$query = "SELECT COUNT(*) FROM stmr";
$link = mysqli_connect("localhost","root", "root", "localDatabase");
$result = mysqli_query($link, $query);
$form_id = mysqli_fetch_array($result)[0] + 1;


if($method == 'GET')
{
 $data = array(
  ':item_id'   => "%" . $_GET['item_id'] . "%",
  ':description'   => "%" . $_GET['description'] . "%",
  ':part_number'   => "%" . $_GET['part_number'] . "%",
  ':unit'     => "%" . $_GET['unit'] . "%",
  ':quantity'    => "%" . $_GET['quantity'] . "%"
 );
 $query = "SELECT * FROM stmrdesc WHERE item_id LIKE :item_id AND description LIKE :description AND part_number LIKE :part_number AND unit LIKE :unit AND quantity LIKE :quantity ORDER BY item_id DESC";

 $statement = $connect->prepare($query);
 $statement->execute($data);
 $result = $statement->fetchAll();
 foreach($result as $row)
 {
  $output[] = array(
   'id' => $row['row_id'],
   'item_id'    => $row['item_id'],   
   'description'  => $row['description'],
   'part_number'   => $row['part_number'],
   'unit'    => $row['unit'],
   'quantity'   => $row['quantity']
  );
 }
 header("Content-Type: application/json");
 echo json_encode($output);
}

if($method == "POST")
{
 $data = array(
  ':item_id'  => $_POST['item_id'],
  ':description'  => $_POST['description'],
  ':part_number'  => $_POST["part_number"],
  ':unit'    => $_POST["unit"],
  ':quantity'   => $_POST["quantity"]
 );

 $query = "INSERT INTO stmrdesc (item_id, description, part_number, unit, quantity) VALUES (:item_id, :description, :part_number, :unit, :quantity)";
 $statement = $connect->prepare($query);
 $statement->execute($data);
}

if($method == 'PUT')
{
 parse_str(file_get_contents("php://input"), $_PUT);
 $data = array(
  ':item_id'   => $_PUT['item_id'],
  ':description' => $_PUT['description'],
  ':part_number' => $_PUT['part_number'],
  ':unit'   => $_PUT['unit'],
  ':quantity'  => $_PUT['quantity']
 );

 $query = "
 UPDATE 'stmrdesc'
 SET 'item_id' = ':item_id', 
 'description' = ':description', 
 'part_number' = ':part_number', 
 'unit' = ':unit', 
 'quantity' = ':quantity' 
 WHERE 'id' = ':id'
 ";
 $statement = $connect->prepare($query);
 $statement->execute($data);
}

if($method == "DELETE")
{
 parse_str(file_get_contents("php://input"), $_DELETE);
 $query = "DELETE FROM stmrdesc WHERE id = '".$_DELETE["id"]."'";
 $statement = $connect->prepare($query);
 $statement->execute();
}

如您所见,我有一个连接到 JSGrid table 的每个按钮的方法,除了编辑和更新数据库中的行。

put sql 语句有 WHERE 'id' = ':id' 但 $data 数组中不存在 ':id'。