Try:

$conditions = array('User.id = User.parent_id');

On Tue, Sep 15, 2009 at 5:51 PM, George <geo...@hakumei.net> wrote:
>
> This seems like a simple thing to do, but I haven't been able to
> figure out how to write the find conditions array to do it. Basically,
> I want to run a query where I check whether one field in the record
> equals another field in the same record. A simple illustration in SQL:
>
> SELECT *
> FROM users as User
> WHERE User.id = User.parent_id
>
> If you make a conditions array like:
>
> $conditions = array('User.id' => 'User.parent_id');
>
> cakePHP generates the SQL as
>
> SELECT *
> FROM users as User
> WHERE User.id = 'User.parent_id'
>
> and it fails on a data conversion error (sql fails trying to convert
> the varchar value 'User.parent_id' to an int).
>
> I couldn't find anything on this in the manual, but surely there's a
> workaround using the cakePHP find conventions rather than resorting to
> just writing the query right?
>
> Thanks for any help you can provide.
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to