如何查询 Zend_Db_Table_Row

发布于 2024-09-16 17:27:04 字数 366 浏览 22 评论 0原文

是否可以针对 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

來不及說愛妳 2024-09-23 17:27:04

考虑定义关系,然后在 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

三人与歌 2024-09-23 17:27:04

您拥有的 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 or Zend_Db_Table class to define the relationships between tables, ZF will then write join statements for you to JOIN tables together, the joined data will then be in your Zend_Db_Table_Row objects after you query the datbase.

Or you can use join() as detailed here to JOIN 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文