如何查询 Zend_Db_Table_Row
是否可以针对 Zend_Db_Table_Row 对象运行 SQL (Zend_Db_Select) 查询?连接两个 Zend_Db_Table_Row 对象怎么样?
我知道这听起来有点迟钝,但我正在处理成百上千行。我已经拥有正在操作的行对象,所以我不想再次查询数据库。
我希望这是清楚的。如果没有,请要求我澄清。
编辑:
澄清一下,对象位于内存中。我已经从数据库中检索了它们。
原因是:
“日志”表中有数千条记录。我需要根据多个用户定义的标准对这些做出反应。处理这些日志时,时间很重要。为了及时实现这一点,需要分叉一个新的流程。为每个日志创建一个新进程。因此,对象已经存在于内存中。
Is it possible to run an SQL (Zend_Db_Select) query against a Zend_Db_Table_Row object? What about joining two Zend_Db_Table_Row objects?
I know it sounds a bit retarded, but I'm processing hundreds and thousands of rows. I already have the row object that I'm manipulating, so I don't want to query the db again.
I hope that's clear. If not, please ask me to clarify.
Edit:
To clarify, the objects are in memory. I've already retrieved them from the database.
The reason for this is:
There are thousands of records in a "log" table. I need to react to these depending on multiple user defined criterion. Time is important when processing these logs. There for a new process is forked to make this happen in a timely manner. A new process is forked for each log. Hence, the objects already exist in memory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
考虑定义关系,然后在 Row 对象上调用 findDependentRowset():
http://framework.zend.com/manual/en/zend.db.table.relationships.html
Consider defining the relationships and then calling findDependentRowset() on the Row object:
http://framework.zend.com/manual/en/zend.db.table.relationships.html
您拥有的
Zend_Db_Table_Row
对象是行,无法查询它们,因为它们不再位于数据库中,它们作为 ZF 的一部分位于内存中。它们是由 PHP 处理的内存中的一组数据 - 它们不再与数据库有任何关系,因此无法按照您的建议查询它们。您应该在模型或
Zend_Db_Table
类中使用findDependentRowset()
来定义表之间的关系,然后 ZF 将为您编写 join 语句来JOIN
表在一起,查询数据库后,连接的数据将位于您的Zend_Db_Table_Row
对象中。或者您可以使用
join()
,详细信息这里将两个或多个表JOIN
在一起。您需要对正在查询的选择对象进行联接。您需要利用数据库引擎的强大功能来获取您需要的数据。在 PHP 中执行此操作比使用数据库慢得多。The
Zend_Db_Table_Row
objects you have are rows, they cannot be queried as they are no longer in the database, they are in memory as part of the ZF. They are a set of data in memory handled by PHP - they no longer have anything to do with the database so they cannot be queried as you are suggesting.You should use
findDependentRowset()
in your models orZend_Db_Table
class to define the relationships between tables, ZF will then write join statements for you toJOIN
tables together, the joined data will then be in yourZend_Db_Table_Row
objects after you query the datbase.Or you can use
join()
as detailed here toJOIN
two or more tables together. You need to do the joins on the select object you are querying. You need to use the power of the database engine to get the data you need. Doing this in PHP is much much slower then using the datbase.