我使用下面的代码在 PHP
中执行 MySQL
查询。
$cus_id = '1';
$query = new QUERY();
$clause = "SELECT * FROM customers WHERE cus_id=:cus_id AND status='ACTIVE'";
$params = array('cus_id'=>$cus_id);
$result = $query->run($clause, $params)->fetchAll();
现在的问题是:它是否足够安全。或者我还需要绑定(bind)静态字符串吗?像这样的东西:
$clause = "SELECT * FROM customers WHERE cus_id=:cus_id AND status=:status";
$params = array('cus_id'=>$cus_id, 'status'=>'ACTIVE');
最佳答案
它是安全的,因为 ACTIVE
不是用户输入的。所以你不需要绑定(bind)它。
关于php - 在 PHP-MySQL 中绑定(bind)变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33348144/