我正在尝试使用sql从表中过滤数据,如下所示:
$select= new \Zend\Db\Sql\Select ;
$select->from('questions');
$select->where(array('questions.id'=>$value));
$select->columns(array('user_id','description'));
$select->join('users', "users.id = questions.user_id", array('username','password'), 'left');
echo $select->getSqlString();
$resultSet = $this->tableGateway->selectWith($select);
return $resultSet;
没有$select->where(array('questions.id'=>$value));
查询执行正常,我可以获取所有数据库值。否则,如果我添加语句,我会收到此错误:
Attempting to quote a value without specific driver level support
can introduce security vulnerabilities in a production environment.
我如何纠正这个以使where子句起作用?
答案 0 :(得分:0)
您可能会发现它正在回显生成该错误的SQL字符串。假设您只是为了调试而执行此操作,删除该行应该修复它。或者,您可以将平台对象传递给函数,例如:
echo $select->getSqlString($this->tableGateway->getAdapter()->getPlatform());