简体   繁体   English

ZF2:在执行SQL语句之前运行MySQL命令“ SET SQL_BIG_SELECTS = 1”

[英]ZF2: run MySQL command “SET SQL_BIG_SELECTS=1” before executing SQL-statements

How do I execute a query (eg SET SQL_BIG_SELECTS=1 ) before running statements in ZF2 (Zend Framework 2)? 在ZF2(Zend Framework 2)中运行语句之前,如何执行查询(例如SET SQL_BIG_SELECTS=1 )?

I tried already setting it in the "driver_options" but with no success. 我尝试已经在“ driver_options”中进行设置,但没有成功。

Usually many statements will be build with \\Zend\\Paginator\\Adapter\\DbTableGateway or \\Zend\\Paginator\\Adapter\\DbSelect. 通常,将使用\\ Zend \\ Paginator \\ Adapter \\ DbTableGateway或\\ Zend \\ Paginator \\ Adapter \\ DbSelect构建许多语句。

I think there should be a hook via the "Shared Manager", but dont know how to implement it. 我认为应该通过“共享管理器”建立一个钩子,但是不知道如何实现它。

Thanks for your help! 谢谢你的帮助!

Pull your adapter instance from the service manager and use the query method to execute it. 从服务管理器中提取适配器实例,并使用query方法执行它。 Alternatively, if the underlying adapter natively supports it you can pass options at the time you configure the adapter. 或者,如果基础适配器本身支持,则可以在配置适配器时传递选项。 There's an example of doing that in the manual comments section, here for a different option (forcing UTF8) 手动注释部分提供了一个示例,此处为其他选项(强制使用UTF8)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM