debugDumpParams()方法
完整测试语句如下:
$query = 'INSERT INTO products
(categoryID, productCode, productName, listPrice)
VALUES
(:category_id, :code, :name2, :price)';
$statement = $db->prepare($query);
$statement->bindValue(':category_id', $category_id);
$statement->bindValue(':code', $code);
$statement->bindValue(':name2', $name);
$statement->bindValue(':price', $price);
$statement->execute();
$statement->debugDumpParams();debugDumpParams后执行
SQL: [210] INSERT INTO products (categoryID, productCode, productName, listPrice,description,dateAdded) VALUES (:category_id, :code, :name2, :price, :description,:dateAdded) Sent SQL: [206] INSERT INTO products (categoryID, productCode, productName, listPrice,description,dateAdded) VALUES ('1', '11133', '222', '333', 'test','2023-03-17 14:03:41') Params: 6 Key: Name: [12] :category_id paramno=-1 name=[12] ":category_id" is_param=1 param_type=2 Key: Name: [5] :code paramno=-1 name=[5] ":code" is_param=1 param_type=2 Key: Name: [6] :name2 paramno=-1 name=[6] ":name2" is_param=1 param_type=2 Key: Name: [6] :price paramno=-1 name=[6] ":price" is_param=1 param_type=2 Key: Name: [12] :description paramno=-1 name=[12] ":description" is_param=1 param_type=2 Key: Name: [10] :dateAdded paramno=-1 name=[10] ":dateAdded" is_param=1 param_type=2复制 INSERT INTO products (categoryID, productCode, productName, listPrice,description,dateAdded) VALUES ('1', '11133', '222', '333', 'test','2023-03-17 14:03:41') 这条sql语句到数据库里执行,检查是否有语法错误。
2107

被折叠的 条评论
为什么被折叠?



