# |
Nov 14th 2017, 10:50 |
willem |
here is what is have now, is there an easier way? ` $query = $query->where([‘start_date <=’ => $today]) ->andWhere([‘end_date >=’ => $today]) ->orWhere(function ($exp) { $q = $exp->and_([ ‘start_date <=’ => $today, ‘end_date is null’, ]); return $q; }); ` |
# |
Nov 14th 2017, 10:50 |
diego182 |
but guess that yes, that's an array |
# |
Nov 14th 2017, 10:49 |
diego182 |
not sure, long time i dont use the property |
# |
Nov 14th 2017, 10:49 |
obinoob |
diego182 that is an array I guess right? |
# |
Nov 14th 2017, 10:47 |
diego182 |
not as a method, but as a property |
# |
Nov 14th 2017, 10:47 |
diego182 |
then use $this->request->query |
# |
Nov 14th 2017, 10:47 |
obinoob |
diego182 maybe I haven't explained my self correctly (it happens a lot :) ) I need the all url query params... unfortunately Warning: Warning (2): Missing argument 1 for Cake\Network\Request::query() it is requesting a params! Perhaps I use a helper... not upgrading now a lot of visual content will simply break because my code is relying on a bootstrap plugin that had a lot of changes :( |
# |
Nov 14th 2017, 10:46 |
neon1024 |
Morning @dereuromark :wave: |
# |
Nov 14th 2017, 10:46 |
dereuromark |
latest minor is always the "only" way to go ;) |
# |
Nov 14th 2017, 10:45 |
diego182 |
3.5 is the way to go IMHO take advantage of PSR7, and start prep the app for CakePHP 4 with all deprecated methods |
# |
Nov 14th 2017, 10:44 |
neon1024 |
Yummy PSR7 |
# |
Nov 14th 2017, 10:43 |
neon1024 |
Or upgrade to 3.5! :) |
# |
Nov 14th 2017, 10:43 |
obinoob |
diego182 that might be the right method :) |
# |
Nov 14th 2017, 10:42 |
obinoob |
neon1024 I can see var_dump($this->request); data and the query is there oubviously ;) also var_dump(get_class($this->request)); returns the name of the class as expected... |
# |
Nov 14th 2017, 10:42 |
neon1024 |
Pre 3.4, good catch :slightly_smiling_face: |
# |
Nov 14th 2017, 10:42 |
neon1024 |
Yes! @diego182 |
# |
Nov 14th 2017, 10:42 |
diego182 |
@obiboob on cakephp 3.1 you have to use `$this->request->query()` |
# |
Nov 14th 2017, 10:39 |
neon1024 |
Well I’m out of ideas then. Sounds to me like you have some debugging to do! |
# |
Nov 14th 2017, 10:39 |
obinoob |
neon1024 no I'm in 3.1 :( |
# |
Nov 14th 2017, 10:39 |
neon1024 |
Even though it’s still `$this->request` even in Cake 2, https://github.com/cakephp/cakephp/blob/2.x/lib/Cake/View/View.php#L195-L202 |
# |
Nov 14th 2017, 10:38 |
neon1024 |
Leading Cake to think you’re looking for a component? |
# |
Nov 14th 2017, 10:38 |
neon1024 |
Perhaps you used a capital R in `request` |
# |
Nov 14th 2017, 10:38 |
neon1024 |
`var_dump(get_class($this->request))` |
# |
Nov 14th 2017, 10:37 |
neon1024 |
Or you’re in Cake 2 perhaps |
# |
Nov 14th 2017, 10:37 |
neon1024 |
If the method does not exist then $this->request isn’t an instance of the request and you have bigger problems |
# |
Nov 14th 2017, 10:37 |
neon1024 |
Here you are, https://github.com/cakephp/cakephp/blob/master/src/Http/ServerRequest.php#L1434-L1458 |
# |
Nov 14th 2017, 10:36 |
neon1024 |
Want me to look that one up for you? |
# |
Nov 14th 2017, 10:36 |
neon1024 |
Well pick the right method ;) |
# |
Nov 14th 2017, 10:35 |
obinoob |
neon1024 Error: [BadMethodCallException] Method getQuery does not exist |
# |
Nov 14th 2017, 10:34 |
obinoob |
perhaps I better set or compact from controller ... |
# |
Nov 14th 2017, 10:34 |
neon1024 |
Then you have a bug elsewhere in your code. Check your logs |
# |
Nov 14th 2017, 10:34 |
obinoob |
neon1024 well I've tested that and I get a 500 status code :/ |
# |
Nov 14th 2017, 10:33 |
neon1024 |
Where $this is a View instance, which has the request -> https://github.com/cakephp/cakephp/blob/master/src/View/View.php#L202-L209 |
# |
Nov 14th 2017, 10:33 |
neon1024 |
obinoob, Yes. It’s just `$this->request->getQuery()` |
# |
Nov 14th 2017, 10:32 |
neon1024 |
https://book.cakephp.org/3.0/en/orm/query-builder.html#advanced-conditions |
# |
Nov 14th 2017, 10:32 |
obinoob |
Hi, Is there any way I can access the all url query string from a view without using $_SERVER['QUERY_STRING'] in worst case? Or filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_SPECIAL_CHARS)? I've read this page but didn't have found any method that actually works... https://book.cakephp.org/3.0/en/controllers/request-response.html#query-string-parameters |
# |
Nov 14th 2017, 10:32 |
neon1024 |
I don’t use the `gte()` functions, but you could use those if you wanted I suppose |
# |
Nov 14th 2017, 10:31 |
neon1024 |
If you need help with an `if()` statement ;P |
# |
Nov 14th 2017, 10:31 |
neon1024 |
Just as you said you would. |
# |
Nov 14th 2017, 10:29 |
willem |
and how would i do this in CakePHP 3 ? |
# |
Nov 14th 2017, 10:20 |
neon1024 |
Yes |