OR condition in eZPersistentObject::fetchObject

Author Message

Claudia Kosny

Thursday 07 December 2006 8:44:00 am

Hi there

How can I create an OR condition in the $cond argument of the eZPersistentObject::fetchObject function? The end result should be something like SELECT * FROM tablename WHERE column_a = 5 OR column_b = 10 .

Thanks

Claudia

Kristof Coomans

Thursday 07 December 2006 11:09:54 pm

Hi Claudia

You will see how the parameter $conds is converted to SQL conditions in eZPersistentObject::conditionTextByRow, but you probably found that yourself ;-) But it doesn't support OR that way.

You'll have to use the last parameter, $custom_conds, which has to be a string of SQL conditions ready to be inserted inside the full SQL query.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Claudia Kosny

Friday 08 December 2006 12:24:54 am

Hi Kristof

The last parameter in my version (ez 3.8.4) is $custom_fields which allows for operations on fields (like count or sum). I don't see a way to use this for an OR condition. Could you give me an example for what you mean?

Thanks

Claudia

Kristof Coomans

Friday 08 December 2006 12:37:29 am

Hi Claudia

It seems like this parameter was added on the trunk (it will be in 3.9), but only to the fetchObjectList function. Because fetchObject calls fetchObjectList, the parameter can be easily added to fetchObject too. Maybe you can post an enhancement request for this?

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Claudia Kosny

Friday 08 December 2006 2:13:52 am

Hi Kristof

Thanks for the answer. I suppose I will just add the option to add custom SQL to my copy of eZPersistentObject::fetchObjectList and eZPersistentObject::fetchObject. As the parameters are optional this should not have any negative effect on any code that makes use of these functions.

Enhancement request is posted http://issues.ez.no/IssueView.php?Id=9767

Claudia

kracker (the)

Friday 08 December 2006 3:19:25 am

Thank you for the issue documentation!

<b>Submit your modification back to the community</b>

Link the forum discussion, issue, patch and documentation together for the community to do as you have. or ...

If you do indeed modify your local copy of eZ publish to meet your own needs would you consider posting a 'patch' or diff of the related source code to support the addition of this feature in stock eZ publish, using the issue systems file attachment feature on your issue.

Cheers,
//kracker

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.