osdir.com
mailing list archive

Subject: Re: query related tables - msg#00080

List: php.zend.framework.db

Date: Prev Next Index Thread: Prev Next Index
Hi Maciej
You're asking Zend_Db_Table to do something it's not designed to do. It implements a Table Data Gateway - a single Table definition. We've added enhancements to this so that you can find/fetch rows from a table based on relationships with other table rows, but not to create composite rows or an ORM-style solution.
Perhaps a better question is to ask why you need your result sets as a Zend_Db_Table_Row? Is it to apply specific Zend_Db_Table(_Row) functionality or simply as a convenience to utilise the iterator/accessor methods?
There's been a lot of requests similar to yours which require large resultsets - I'd be keen to find out if there's a solution to your problem that addresses your needs more directly. Can you provide a use case or further information on your application?

Hi all,maybe someone can give me an explanation, how can I solve described problem in the most efficient way, I use Zend_Db_Table for app which i am working on , everything  is ok when I need to use just simple queries or when a datasets aren’t huge. But now I need to get much more than 1000 records at once from one table, these records are related with 3 others tables. The business object where domain logic is, need data from each table, well... I don’t think it would  be efficient to get  all the records via Zend’s fetch...() method and next call getRelated... on each row. So I need to use just one query, get all data at once, put them into TableModule where business logic would be applied. I know how do it in plain SQL but I would like to get objets extend Zend_Db_Table_Row with others objects from related tables.    
--
Simon Mundy | Director | PEPTOLAB
""" " "" """""" "" "" """"""" " "" """"" " """"" "  """""" "" "
202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124http://www.peptolab.com
Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: Missing refresh() method in Zend_Db_Table_Row_Abstract

Hi Justin - sorry, I had no knowledge of it. I'll reapply this patch ASAP and see if we can migrate it across to 1.5PR Cheers I added a public refresh() method to Zend_Db_Table_Row_Abstract in a previous commit which seems to have been lost when all of the Zend_Db changes were merged into the trunk and the release-1.5PR branch. I have already re-commited this patch to the trunk and I was wondering if someone could please commit the attached patch to the release-1.5PR branch. This fixes ZF-2185. Thanks. -Justin <Zend_Db_Table_Row_Abstract refresh.diff> -- Simon Mundy | Director | PEPTOLAB """ " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" " 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000 Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124 http://www.peptolab.com

Next Message by Date: click to view message preview

RE: query related tables

thanks for advice, your idea is really nice, I will have to take a closer look at it. best regards -----Original Message----- From: EranGalperin [mailto:eran-CMOV2Mh6R/VBDgjK7y7TUQ@xxxxxxxxxxxxxxxx] Sent: Saturday, January 26, 2008 12:16 AM To: fw-db-wwOhfgvld6hpLGFMi4vTTA@xxxxxxxxxxxxxxxx Subject: Re: [fw-db] query related tables Current implementation of Zend_Db_Table isn't built for performance or for performing table joins. You can have a look at my proposal for an adapter between manual SQL query building and the Zend_Db_Table structure - called Zend_Db_Gateway (under new proposals). After retrieving you data, uou can then replace the fetchAll() method with a custom one that will generate Zend_Db_Rowset for you to work with in the following manner: <?php //From inside a Zend_Db_Table instance function myFetchAll() { // name appropriately to the type of data returned $rowsetData = $this -> myMagicDataMethod(); // Replace this with your actual data fetching routine $data = array( 'table' => $this, 'data' => $rowsetData, //This is your retrieved data joined from several tables 'rowClass' => $this->_rowClass, //Or an optional custom class 'stored' => true ); return new Zend_Db_Table_Rowset($data); } ?> Just remember not to use any of the Zend_Db_Row save() or delete() methods for unexpected results, since they were not built to handle data from multiple tables Maciej Guzek wrote: > > Hi all, > > maybe someone can give me an explanation, how can I solve described > problem in the most efficient way, I use Zend_Db_Table for app which i > am working on , everything is ok when I need to use just simple queries > or when a datasets aren't huge. But now I need to get much more than > 1000 records at once from one table, these records are related with 3 > others tables. The business object where domain logic is, need data from > each table, well... I don't think it would be efficient to get all the > records via Zend's fetch...() method and next call getRelated... on each > row. So I need to use just one query, get all data at once, put them > into TableModule where business logic would be applied. I know how do it > in plain SQL but I would like to get objets extend Zend_Db_Table_Row > with others objects from related tables. > -- View this message in context: http://www.nabble.com/query-related-tables-tp15098365s16154p15098961.htm l Sent from the Zend DB mailing list archive at Nabble.com.

Previous Message by Thread: click to view message preview

Re: query related tables

Current implementation of Zend_Db_Table isn't built for performance or for performing table joins. You can have a look at my proposal for an adapter between manual SQL query building and the Zend_Db_Table structure - called Zend_Db_Gateway (under new proposals). After retrieving you data, uou can then replace the fetchAll() method with a custom one that will generate Zend_Db_Rowset for you to work with in the following manner: <?php //From inside a Zend_Db_Table instance function myFetchAll() { // name appropriately to the type of data returned $rowsetData = $this -> myMagicDataMethod(); // Replace this with your actual data fetching routine $data = array( 'table' => $this, 'data' => $rowsetData, //This is your retrieved data joined from several tables 'rowClass' => $this->_rowClass, //Or an optional custom class 'stored' => true ); return new Zend_Db_Table_Rowset($data); } ?> Just remember not to use any of the Zend_Db_Row save() or delete() methods for unexpected results, since they were not built to handle data from multiple tables Maciej Guzek wrote: > > Hi all, > > maybe someone can give me an explanation, how can I solve described > problem in the most efficient way, I use Zend_Db_Table for app which i > am working on , everything is ok when I need to use just simple queries > or when a datasets aren't huge. But now I need to get much more than > 1000 records at once from one table, these records are related with 3 > others tables. The business object where domain logic is, need data from > each table, well... I don't think it would be efficient to get all the > records via Zend's fetch...() method and next call getRelated... on each > row. So I need to use just one query, get all data at once, put them > into TableModule where business logic would be applied. I know how do it > in plain SQL but I would like to get objets extend Zend_Db_Table_Row > with others objects from related tables. > -- View this message in context: http://www.nabble.com/query-related-tables-tp15098365s16154p15098961.html Sent from the Zend DB mailing list archive at Nabble.com.

Next Message by Thread: click to view message preview

RE: query related tables

thanks for advice, your idea is really nice, I will have to take a closer look at it. best regards -----Original Message----- From: EranGalperin [mailto:eran-CMOV2Mh6R/VBDgjK7y7TUQ@xxxxxxxxxxxxxxxx] Sent: Saturday, January 26, 2008 12:16 AM To: fw-db-wwOhfgvld6hpLGFMi4vTTA@xxxxxxxxxxxxxxxx Subject: Re: [fw-db] query related tables Current implementation of Zend_Db_Table isn't built for performance or for performing table joins. You can have a look at my proposal for an adapter between manual SQL query building and the Zend_Db_Table structure - called Zend_Db_Gateway (under new proposals). After retrieving you data, uou can then replace the fetchAll() method with a custom one that will generate Zend_Db_Rowset for you to work with in the following manner: <?php //From inside a Zend_Db_Table instance function myFetchAll() { // name appropriately to the type of data returned $rowsetData = $this -> myMagicDataMethod(); // Replace this with your actual data fetching routine $data = array( 'table' => $this, 'data' => $rowsetData, //This is your retrieved data joined from several tables 'rowClass' => $this->_rowClass, //Or an optional custom class 'stored' => true ); return new Zend_Db_Table_Rowset($data); } ?> Just remember not to use any of the Zend_Db_Row save() or delete() methods for unexpected results, since they were not built to handle data from multiple tables Maciej Guzek wrote: > > Hi all, > > maybe someone can give me an explanation, how can I solve described > problem in the most efficient way, I use Zend_Db_Table for app which i > am working on , everything is ok when I need to use just simple queries > or when a datasets aren't huge. But now I need to get much more than > 1000 records at once from one table, these records are related with 3 > others tables. The business object where domain logic is, need data from > each table, well... I don't think it would be efficient to get all the > records via Zend's fetch...() method and next call getRelated... on each > row. So I need to use just one query, get all data at once, put them > into TableModule where business logic would be applied. I know how do it > in plain SQL but I would like to get objets extend Zend_Db_Table_Row > with others objects from related tables. > -- View this message in context: http://www.nabble.com/query-related-tables-tp15098365s16154p15098961.htm l Sent from the Zend DB mailing list archive at Nabble.com.
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by