Hi everyone,

I've searched long and hard to find an answer to this but haven't had
luck. Tried IRC but didn't ever get a response from anyone.

Using the 1.3 branch, Is it possible to use a virtual field in a find
condition? Using the classic example,

var $virtualFields = array(
  'name' => 'CONCAT(Profile.first_name, " ", Profile.last_name)'
);

$this->Profile->find('all', array(
  'conditions' => array(
    'Profile.name LIKE' => 'har'
  )
));

You get the idea. The closest I've found is a forked cakephp version
on Git that supports this sort of thing (at least, it has commits that
say so). I've also done a little work where when parsing conditions I
use something like:
$conditions[$this->Profile->getVirtualField('name')] = 'har';

I don't like that above workaround for a ton of reasons. I've also
tried to directly refer to the generated alias (Profile__name) to no
avail. I'm no MySQL expert, so maybe there's a quirk with the double
underscore I'm not aware of.

If it's simply not supported as of yet, that's fine. I'll stop beating
myself up trying to figure out what I'm doing wrong ;)

-jharris

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to