Log message #4096623

# At Username Text
# Nov 14th 2017, 11:54 stoykovnet @willem, wouldn't that suffice? ``` // In some model class. public function findBetweenDates(Query $query, array $options) { return $query->where([ 'OR' => [ ['start_date <=' => $options['today'], 'end_date >=' => $options['today']] ['start_date <=' => $options['today'], 'end_date IS' => null] ] ]); } ```
# Nov 14th 2017, 11:54 neon1024 What query are you trying to write?
# Nov 14th 2017, 11:48 diego182 @willem you can use queryExpressions with $exp->or_ or as array
# Nov 14th 2017, 11:47 obinoob if you feel fine with sql
# Nov 14th 2017, 11:47 obinoob willen above you can read a very simple example on how to use ConnectionManager
# Nov 14th 2017, 11:46 obinoob https://gist.github.com/obinoob/6182a57343f5b8b04cfc57d2d2fa6e1d
# Nov 14th 2017, 11:46 obinoob willem you can either create a query by using the ORM or PDO with prepared statments prety easy...
# Nov 14th 2017, 11:37 willem yes, i noticed, but I have no clue how to create the query. I find it difficult to create an more advanced query using Cake, whilst writing in sql would be easy. Of course i want to use the framework to create the query.
# Nov 14th 2017, 11:03 diego182 awesome!
# Nov 14th 2017, 11:02 obinoob diego182 didn't had a clue about this function existence thank you again http://php.net/manual/en/function.http-build-query.php
# Nov 14th 2017, 11:02 obinoob diego182 that will work just fine :) thank you
# Nov 14th 2017, 11:00 obinoob I've read the api documentation for 3.1 (fast reading :) ) and the api does not provide any method that can retrieve the full query :(
# Nov 14th 2017, 10:56 diego182 cakephp use http_build_query internally in some functions
# Nov 14th 2017, 10:56 diego182 `http_build_query($this->request->query)`
# Nov 14th 2017, 10:55 obinoob this seems awkward
# Nov 14th 2017, 10:54 obinoob So does 3.1 provide me with any method/property that can handle the url complete query or do I have to create a helper function?
# Nov 14th 2017, 10:54 diego182 he is using cakephp 3.1
# Nov 14th 2017, 10:53 saeideng ` $this->request->query` deprecated
# Nov 14th 2017, 10:52 diego182 `orWhere` is now deprecated
# Nov 14th 2017, 10:51 saeideng dont use `orWhere`
# Nov 14th 2017, 10:51 diego182 maybe you could use in conjunction with PHP native http_build_query
# 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