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?
Is there some configuration that I have to set?
Thanks
Sergio Rinaudo
> Date: Thu, 23 Jul 2009 09:29:22 +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,
> > Thank you for your reply.
> > Unfortunatelly I already know and use the array you talking about.
> >
> > My problem is that my subquery is a join between 7 or 8 tables,
> > and that array is something like
> >
> > array('COUNT(*) AS number')
> >
> > but zend framework's select object adds tablename.* for each table
> > I've joined in my query, for example, my query become something like
> >
> > SELECT COUNT(*) AS number, table1.*, table2.*, [...] tableN
> >
> > And I get an error.
> > How to tell zend select to not add those fields?
>
> The second argument that you can pass to from() also applies to join*(),
> except as the third argument. (Side note: you can use an associative
> array instead of the "AS" keyword).
>
> $db->select()->from('table1', array('number' => 'COUNT(*)'))
> ->joinInner('table2', 'table1.id = table2.table1_id', array())
> ...
>
> If this is not what you mean, maybe you could post a code snippet to
> help us understand.
>
> - --
>
> 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
>
> iEYEARECAAYFAkpnoMwACgkQ7bkAtAithusSNQCgq4Id0o1jBMm4KuMWQ/PgVtaJ
> HL4An1DAPy+OkB9c783elqFDWTkzY5H0
> =UMnK
> -----END PGP SIGNATURE-----
_________________________________________________________________
Accendi le casse, รจ ora della Messenger Radio!
http://www.messenger.it/radioMessenger.aspx