Forums / Developer / OR condition in eZPersistentObject::fetchObject

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/

eZ debug

Timing: Jan 18 2025 15:08:29
Script start
Timing: Jan 18 2025 15:08:29
Module start 'content'
Timing: Jan 18 2025 15:08:31
Module end 'content'
Timing: Jan 18 2025 15:08:31
Script end

Main resources:

Total runtime1.4290 sec
Peak memory usage4,096.0000 KB
Database Queries205

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0068 588.9766180.8125
Module start 'content' 0.00681.2638 769.7891615.4766
Module end 'content' 1.27060.1583 1,385.2656337.0547
Script end 1.4289  1,722.3203 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00430.3001210.0002
Check MTime0.00150.1049210.0001
Mysql Total
Database connection0.00050.034410.0005
Mysqli_queries1.348094.33112050.0066
Looping result0.00220.15642030.0000
Template Total1.399597.920.6998
Template load0.00210.143620.0010
Template processing1.397597.793620.6987
Template load and register function0.00020.016510.0002
states
state_id_array0.00130.090110.0013
state_identifier_array0.00230.158620.0011
Override
Cache load0.00180.1268340.0001
Sytem overhead
Fetch class attribute can translate value0.00160.111240.0004
Fetch class attribute name0.00140.096780.0002
XML
Image XML parsing0.00150.103740.0004
class_abstraction
Instantiating content class attribute0.00000.001390.0000
General
dbfile0.00290.2011350.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs