我创建了这篇关于如何在zend框架1中使用预处理语句的有趣帖子
How to use prepared statements in Zend Framework
我想在Zend Framework 2中做同样的事情
类似
$sql = "UPDATE foo set bar = :value where id = :id"
$this->tableGateway->getAdapter()->queryPrepareStatement($sql, array('value' => 'some value', 'id' => 123)
答案 0 :(得分:3)
我找到了一种使用tableGateway
的简单方法$sql = "UPDATE foo set bar = :value where id = :id"
$data = array('value' => 'some value', 'id' => 123)
$stmt = $this->tableGateway->getAdapter()->createStatement($sql);
$stmt->prepare($sql);
return $stmt->execute($data);