A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearHow do I quickly create a complex select query using Zend_Db? - page 1
User InfoPosts
How do I quickly create a complex select query using Zend_Db?#1
Let's say have something like:

SELECT energy_produced, energy_consumed, timestamp1 AS timestamp FROM (
SELECT max(energy_produced) AS energy_produced, mid(timestamp, 1, 10) AS timestamp1 FROM tbl_energy
WHERE site_id = 1366 AND mid(timestamp, 1, 10) >= DATE_SUB(curdate(),INTERVAL 1 day)
group by mid(timestamp1, 1, 10)) AS e1
INNER JOIN (
SELECT max(energy_consumed) AS energy_consumed, mid(timestamp, 1, 10) AS timestamp2 FROM tbl_energy
WHERE site_id = 1366 AND mid(timestamp, 1, 10) >= DATE_SUB(curdate(),INTERVAL 1 day)
group by mid(timestamp2, 1, 10)) AS e2
ON e1.timestamp1 = e2.timestamp2


Can I just stuff it in a variable and call the sucker like $db->fetchAll($select)->toArray?

posted date: 2008-12-12 17:55:00


Re: How do I quickly create a complex select query using Zend_Db?#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-12 17:55:01


Re: How do I quickly create a complex select query using Zend_Db?#3
Yes, you can pass a SQL statement as a string to the $db->fetchAll() method. You don't need to call toArray() on the result, because the result is already returned as an array by default. The Zend_Db_Table class also has a fetchAll() method, but it doesn't take a SQL string, and it returns a Zend_Db_Table_Rowset object.

posted date: 2008-12-12 18:04:00


Re: How do I quickly create a complex select query using Zend_Db?#4
Worked like a charm. Thanks so much Bill!

posted date: 2008-12-12 18:15:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.