我有一个返回Zend\Db\Sql\Select对象的类。
在使用phpunit的测试中,我尝试通过
var_dump($select->getSqlString());但我收到一条错误信息:
Attempting to quote a value without specific driver level
support can introduce security vulnerabilities in a
production environment.在我的phpunit引导程序中定义
putenv('APP_ENV=test');我也试过
var_dump($select->getSqlString(new \Zend\Db\Adapter\Platform\Mysql()));但也会有类似的错误
Attempting to quote a value in Zend\Db\Adapter\Platform\Mysql
without extension/driver support can introduce security
vulnerabilities in a production environment.在没有数据库适配器/驱动程序的情况下,我怎样才能在测试中获得字符串?
发布于 2013-12-04 03:29:55
$adapter = new \Zend\Db\Adapter\Adapter ([
'driver' => 'Pdo',
'dsn' => 'sqlite:./test.sql',
]);
$where = new \Zend\Db\Sql\Where();
$where->orPredicate (new \Zend\Db\Sql\Predicate\Like('table.cat1', 1))
->orPredicate (new \Zend\Db\Sql\Predicate\Like('cat2', 2));
$sql = new \Zend\Db\Sql\Sql ($adapter);
$select = $sql->select ();
$select->from ('table')->where ($where);
echo $sql->getSqlStringForSqlObject ($select);发布于 2016-03-03 09:19:01
@acond
$sql->getSqlStringForSqlObject ($select)被废弃,更好的利用
$sql->buildSqlString($select)
https://stackoverflow.com/questions/20362801
复制相似问题