<![CDATA[ where = empty field get a wrong result - My Forums]]> https://forums.modx.com/thread/?thread=101714 <![CDATA[where = empty field get a wrong result]]> https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548565
In my getPage call, I have:
&where=`{"datestart:>=":"[[!today]]"},{"OR:dateend:>=":"[[!today]]"}`


But, if `dateend`is empty, I have all results.

Of course, this code work perfectly:
&where=`{"datestart:>=":"[[!today]]"}`


Help!]]>
neoziox Feb 06, 2017, 03:14 PM https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548565
<![CDATA[Re: where = empty field get a wrong result]]> https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548640 Quote from: Bruno17 at Feb 09, 2017, 08:17 AM
I would use a custom-table and a MIGXdb - TV or create a MIGXdb - CMP

I thought this solution. First time that I use MIGXdb.
I hope that I will can sort more easier (when we have a start and end date).]]>
neoziox Feb 09, 2017, 09:02 AM https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548640
<![CDATA[Re: where = empty field get a wrong result]]> https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548637 Bruno17 Feb 09, 2017, 08:17 AM https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548637 <![CDATA[Re: where = empty field get a wrong result]]> https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548636 Quote from: treigh at Feb 09, 2017, 12:20 AM
So you're using MIGX, not getResources? It would be useful if you posted your full getPage call. All the answers, mine included, have assumed you were using getResources in your getPage call. FYI Articles uses getResources to list resources and I'm not sure you'll be well served with Articles.

OK, sorry. My bad. This is my call:

[[!getPage?
					&element=`getImageList`
					&tpl=`agenda.aside`
					&docid=`16`
					&limit=`5`
					&tvname=`agenda`
					&sort=`[{"sortby":"datestart","sortdir":"ASC"}]`
					&where=`{"datestart:>=":"[[!today]]"},{"OR:dateend:>=":"[[!today]]"}`
				]]


The TV `agenda` is a list of several events which use MIGX. But, with the time of using, I'm afraid that list will be too long to use. So, what is your advice?

PS I'm aware that this post is not in the right place now and I apologize.]]>
neoziox Feb 09, 2017, 07:24 AM https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548636
<![CDATA[Re: where = empty field get a wrong result]]> https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548627 treigh Feb 09, 2017, 12:20 AM https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548627 <![CDATA[Re: where = empty field get a wrong result]]> https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548613 Quote from: bwente at Feb 07, 2017, 09:02 PM
How about a different approach? Since it sounds like you are using getResources can you use the publish and unpublish dates?

I am using this...

[[!getPage@Events?
     &elementClass=`modSnippet`
     &element=`getResources`
     &includeTVs=`1`
     &tvPrefix =``
     &tpl=`tpl.Events`
     &showHidden=`1`
     &sortbyTV=`startTime`
     &sortdirTV=`ASC`
     &sortbyTVType=`datetime`
]]

<div class="text-center">
     <ul class="pagination">[[!+page.nav]]</ul>
</div>

I wonder if it's not better if I use Articles instead of MIGX. Articles or another Extra, what is your opinion?]]>
neoziox Feb 08, 2017, 12:52 PM https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548613
<![CDATA[Re: where = empty field get a wrong result]]> https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548606
I am using this...

[[!getPage@Events?
     &elementClass=`modSnippet`
     &element=`getResources`
     &includeTVs=`1`
     &tvPrefix =``
     &tpl=`tpl.Events`
     &showHidden=`1`
     &sortbyTV=`startTime`
     &sortdirTV=`ASC`
     &sortbyTVType=`datetime`
]]

<div class="text-center">
     <ul class="pagination">[[!+page.nav]]</ul>
</div>
]]>
bwente Feb 07, 2017, 09:02 PM https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result?page=2#dis-post-548606
<![CDATA[Re: where = empty field get a wrong result]]> https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result#dis-post-548576 Quote from: treigh at Feb 06, 2017, 06:13 PM
With the where clause, getResources queries modResource standard object fields. I suspect that your datestart and dateend are TVs, not resource fields. What you need is the tvFilters property or a more complex query using a custom snippet.

With &tvFilters you could do this (untested):
&tvFilters=`datestart>=[[!today]]%,dateend>=[[!today]]%`


Also, I'd advise converting your dates to unix timestamps when comparing against another date. That way you're dealing with numbers instead of strings.

Same result :/]]>
neoziox Feb 06, 2017, 06:31 PM https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result#dis-post-548576
<![CDATA[Re: where = empty field get a wrong result]]> https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result#dis-post-548575 tvFilters property or a more complex query using a custom snippet.

With &tvFilters you could do this (untested):
&tvFilters=`datestart>=[[!today]]%,dateend>=[[!today]]%`


Also, I'd advise converting your dates to unix timestamps when comparing against another date. That way you're dealing with numbers instead of strings.]]>
treigh Feb 06, 2017, 06:13 PM https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result#dis-post-548575
<![CDATA[Re: where = empty field get a wrong result]]> https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result#dis-post-548574
<?php
return date('Y-m-d H:i:s');
]]>
neoziox Feb 06, 2017, 05:51 PM https://forums.modx.com/thread/101714/where-empty-field-get-a-wrong-result#dis-post-548574