Hi, I think you correctly answered to my question. I was confusing the array as second parameter of the 'from' method with the array as the third parameter of the join/joinInner/joinLeft method.
I actually DON'T use an empty array as join method's third param. I cannot do a test right now, but as your example, I'm sure this is the solution. Thank you very much! Sergio Rinaudo > Date: Thu, 23 Jul 2009 10:04:35 +1000 > From: [email protected] > To: [email protected] > CC: [email protected] > Subject: Re: [fw-general] Problem with subquery > > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Sergio Rinaudo wrote: > > Hi, > > thanks or the tip about the associative array insted of the 'AS' > > keyword, I missed it. > > > > Lets take your example, I use the $select variable to store the object > > > > > > $select = $db->select()->from('table1', array('number' => 'COUNT(*)')) > > ->joinInner('table2', 'table1.id = table2.table1_id', array()) > > > > My query is created in the same manner as this example. > > If I do > > > > echo $select > > > > I obtain > > > > SELECT COUNT(*) AS number, *table1.*, table2.** [...] > > > > I don't want table1.*, table2.* ecc, because they cause an error if the > > query it is a subquery, and a subquery expects only a field. > > > > Is this happening only to me? > > It's not happening to me, I was running on memory previously, but I've > just tested and this: > > $db = Zend_Db::factory('Pdo_Sqlite', array('dbname' => '/tmp/db.sqlite')); > $select = $db->select() > ->from('table1', array('count' => 'COUNT(*)')) > ->joinInner('table2', 'table1.id = table2.table1_id'); > echo $select; > > produces: > > SELECT COUNT(*) AS "count", "table2".* FROM "table1" INNER JOIN "table2" > ON table1.id = table2.table1_id > > but this: > > $db = Zend_Db::factory('Pdo_Sqlite', array('dbname' => '/tmp/db.sqlite')); > $select = $db->select() > ->from('table1', array('count' => 'COUNT(*)')) > ->joinInner('table2', 'table1.id = table2.table1_id', array()); > echo $select; > > produces: > > SELECT COUNT(*) AS "count" FROM "table1" INNER JOIN "table2" ON > table1.id = table2.table1_id > > And I'm fairly sure that is how it is explained in the documentation. If > that is not the same result you are getting it seems there is a problem > somewhere else. > > > Is there some configuration that I have to set? > > My tests were run on a completely vanilla setup, instantiating nothing > but the autoloader. So, no special configuration there. > > So, unless there is more information, I'm out of ideas :( > > - -- > > Brenton Alker > PHP Developer - Brisbane, Australia > > http://blog.tekerson.com/ > -----BEGIN PGP SIGNATURE----- > Version: GnuPG v1.4.9 (GNU/Linux) > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org > > iEYEARECAAYFAkpnqQ0ACgkQ7bkAtAithus0JACgsHAWut6raogCdndRJThWk6SC > /GEAn3Qmtx/rew2tqLNDcqbBsOPVpqCA > =nag5 > -----END PGP SIGNATURE----- _________________________________________________________________ Con Windows Live, puoi organizzare, modificare e condividere le tue foto. http://www.microsoft.com/italy/windows/windowslive/products/photo-gallery-edit.aspx
