Issue with prepared statements using Doctrine_RawSql
The group you are posting to is a
Usenet group . Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From:
bmills <br... @millz.net>
Date: Tue, 7 Jul 2009 11:06:24 -0700 (PDT)
Local: Tues 7 July 2009 19:06
Subject: Issue with prepared statements using Doctrine_RawSql
I'm having some issue using prepared statements in Doctrine_RawSql.
Using a query like this:
$q = new Doctrine_RawSql();
$result = $q->select('{p.*}')
->from('photographers p')
->addComponent('p', 'Photographer')
->where('p.city_id = ?')
->orderBy('CASE WHEN p.lname < ? THEN 1 ELSE 0 END,
p.lname ASC')
->execute(array(35, "foo%"));
Yields SQL like this:
echo $q->getSql();
SELECT [list of fields]
FROM photographers p
WHERE p.city_id = ?
ORDER BY
CASE WHEN p.lname < ? THEN 1 ELSE 0 END, p.lname ASC
Any idea why my parameters aren't substituted into the query? Thanks!
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
eXtreme <jacek.jedrzejew... @gmail.com>
Date: Tue, 7 Jul 2009 11:52:31 -0700 (PDT)
Local: Tues 7 July 2009 19:52
Subject: Re: Issue with prepared statements using Doctrine_RawSql
Because this process happens internally in PDO :P
On 7 Lip, 20:06, bmills <br... @millz.net> wrote:
> I'm having some issue using prepared statements in Doctrine_RawSql.
> Using a query like this:
> $q = new Doctrine_RawSql();
> $result = $q->select('{p.*}')
> ->from('photographers p')
> ->addComponent('p', 'Photographer')
> ->where('p.city_id = ?')
> ->orderBy('CASE WHEN p.lname < ? THEN 1 ELSE 0 END,
> p.lname ASC')
> ->execute(array(35, "foo%"));
> Yields SQL like this:
> echo $q->getSql();
> SELECT [list of fields]
> FROM photographers p
> WHERE p.city_id = ?
> ORDER BY
> CASE WHEN p.lname < ? THEN 1 ELSE 0 END, p.lname ASC
> Any idea why my parameters aren't substituted into the query? Thanks!
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
bmills <br... @millz.net>
Date: Tue, 7 Jul 2009 12:28:43 -0700 (PDT)
Local: Tues 7 July 2009 20:28
Subject: Re: Issue with prepared statements using Doctrine_RawSql
So you're saying Doctrine_RawSql() bypasses PDO all together? Would I
be better off working with a PDO object directly?
An an aside, is there anyway to use the '->orderBy(CASE WHEN .. )'
statement in DQL without getting an Unkown Aggregate exception?
On Jul 7, 2:52 pm, eXtreme <jacek.jedrzejew... @gmail.com> wrote:
> Because this process happens internally in PDO :P
> On 7 Lip, 20:06, bmills <br... @millz.net> wrote:
> > I'm having some issue using prepared statements in Doctrine_RawSql.
> > Using a query like this:
> > $q = new Doctrine_RawSql();
> > $result = $q->select('{p.*}')
> > ->from('photographers p')
> > ->addComponent('p', 'Photographer')
> > ->where('p.city_id = ?')
> > ->orderBy('CASE WHEN p.lname < ? THEN 1 ELSE 0 END,
> > p.lname ASC')
> > ->execute(array(35, "foo%"));
> > Yields SQL like this:
> > echo $q->getSql();
> > SELECT [list of fields]
> > FROM photographers p
> > WHERE p.city_id = ?
> > ORDER BY
> > CASE WHEN p.lname < ? THEN 1 ELSE 0 END, p.lname ASC
> > Any idea why my parameters aren't substituted into the query? Thanks!
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
eXtreme <jacek.jedrzejew... @gmail.com>
Date: Tue, 7 Jul 2009 13:42:59 -0700 (PDT)
Local: Tues 7 July 2009 21:42
Subject: Re: Issue with prepared statements using Doctrine_RawSql
RawSql and DQL still finally lead to.. PDO :P What's wrong with it for
you?
Regarding the orderby, I'm not sure.. You have RawSql for such
operations ;d
On 7 Lip, 21:28, bmills <br... @millz.net> wrote:
> So you're saying Doctrine_RawSql() bypasses PDO all together? Would I
> be better off working with a PDO object directly?
> An an aside, is there anyway to use the '->orderBy(CASE WHEN .. )'
> statement in DQL without getting an Unkown Aggregate exception?
> On Jul 7, 2:52 pm, eXtreme <jacek.jedrzejew... @gmail.com> wrote:
> > Because this process happens internally in PDO :P
> > On 7 Lip, 20:06, bmills <br... @millz.net> wrote:
> > > I'm having some issue using prepared statements in Doctrine_RawSql.
> > > Using a query like this:
> > > $q = new Doctrine_RawSql();
> > > $result = $q->select('{p.*}')
> > > ->from('photographers p')
> > > ->addComponent('p', 'Photographer')
> > > ->where('p.city_id = ?')
> > > ->orderBy('CASE WHEN p.lname < ? THEN 1 ELSE 0 END,
> > > p.lname ASC')
> > > ->execute(array(35, "foo%"));
> > > Yields SQL like this:
> > > echo $q->getSql();
> > > SELECT [list of fields]
> > > FROM photographers p
> > > WHERE p.city_id = ?
> > > ORDER BY
> > > CASE WHEN p.lname < ? THEN 1 ELSE 0 END, p.lname ASC
> > > Any idea why my parameters aren't substituted into the query? Thanks!
You must
Sign in before you can post messages.
You do not have the permission required to post.
From:
bmills <br... @millz.net>
Date: Tue, 7 Jul 2009 14:19:56 -0700 (PDT)
Local: Tues 7 July 2009 22:19
Subject: Re: Issue with prepared statements using Doctrine_RawSql
Sorry, I misunderstood your first comment. $q->getSql() is the query
before PDO happens. So I've probably been barking up the wrong tree
all day. Thanks though!
On Jul 7, 4:42 pm, eXtreme <jacek.jedrzejew... @gmail.com> wrote:
> RawSql and DQL still finally lead to.. PDO :P What's wrong with it for
> you?
> Regarding the orderby, I'm not sure.. You have RawSql for such
> operations ;d
> On 7 Lip, 21:28, bmills <br... @millz.net> wrote:
> > So you're saying Doctrine_RawSql() bypasses PDO all together? Would I
> > be better off working with a PDO object directly?
> > An an aside, is there anyway to use the '->orderBy(CASE WHEN .. )'
> > statement in DQL without getting an Unkown Aggregate exception?
> > On Jul 7, 2:52 pm, eXtreme <jacek.jedrzejew... @gmail.com> wrote:
> > > Because this process happens internally in PDO :P
> > > On 7 Lip, 20:06, bmills <br... @millz.net> wrote:
> > > > I'm having some issue using prepared statements in Doctrine_RawSql.
> > > > Using a query like this:
> > > > $q = new Doctrine_RawSql();
> > > > $result = $q->select('{p.*}')
> > > > ->from('photographers p')
> > > > ->addComponent('p', 'Photographer')
> > > > ->where('p.city_id = ?')
> > > > ->orderBy('CASE WHEN p.lname < ? THEN 1 ELSE 0 END,
> > > > p.lname ASC')
> > > > ->execute(array(35, "foo%"));
> > > > Yields SQL like this:
> > > > echo $q->getSql();
> > > > SELECT [list of fields]
> > > > FROM photographers p
> > > > WHERE p.city_id = ?
> > > > ORDER BY
> > > > CASE WHEN p.lname < ? THEN 1 ELSE 0 END, p.lname ASC
> > > > Any idea why my parameters aren't substituted into the query? Thanks!
You must
Sign in before you can post messages.
You do not have the permission required to post.