du1843 2014-03-24 19:17
浏览 47
已采纳

可以将原始SQL解析为Zend \ Db \ Sql \ Select对象吗?

is there a way to parse a SQL statement string into a Zend\Db\Sql\Select object?

something along the lines of:

$sql = 'SELECT * FROM table WHERE col1 = "x"';
$select = new Select();
$select->parseSql($sql);

I have many uses for this, basically maintaining the use of a Select object when executing a raw SQL statement, for example to pass to Zend\Paginator\Adapter\DbSelect without having to write a custom Zend\Paginator\Adapter\DbSelect Class.

  • 写回答

1条回答 默认 最新

  • doukezi4606 2014-03-25 19:39
    关注

    got one answer through a twitter response, specific to the Paginator use case:

    $resultSet = iterator_to_array($adapter->query($sql_statement)->execute());
    $iteratorAdapter = new ArrayAdapter($resultSet);
    $paginator = new Paginator($iteratorAdapter);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部