Log message #4201831

# At Username Text
# Sep 5th 2019, 13:52 ricksaccous if you debug after calling toArray()
# Sep 5th 2019, 13:51 g.catania nothing changed
# Sep 5th 2019, 13:51 g.catania I tried already both toArray() and execute()
# Sep 5th 2019, 13:50 ricksaccous lol
# Sep 5th 2019, 13:50 ricksaccous as for why cache even affects that I dunno
# Sep 5th 2019, 13:49 ricksaccous toArray executes the query
# Sep 5th 2019, 13:49 ricksaccous I suppose the query hasn't been executed yet, I think you're not getting a ResultSet object back when you cache, but without cache you are getting one
# Sep 5th 2019, 13:48 ricksaccous ->cache('something')->toArray();
# Sep 5th 2019, 13:48 ricksaccous try adding toArray after cache
# Sep 5th 2019, 13:47 g.catania if I omit the ->cache() part works
# Sep 5th 2019, 13:46 g.catania foreach ($user_capabilities as ....) <- this throws the error reported above
# Sep 5th 2019, 13:46 g.catania $user_capabilities = $this->Capabilities->find() ->contain('CapabilityGroups') ->matching('Groups.Users', function($q) { return $q->where(['Users.id' => $this->request->getSession()->read('Auth.User.id')]); })->cache("capabilities-".$this->request->getSession()->read('Auth.User.id'), 'capabilities');
# Sep 5th 2019, 13:42 g.catania I'm running on CakePHP 3.0.x
# Sep 5th 2019, 13:42 ricksaccous @g.catania show code
# Sep 5th 2019, 13:41 g.catania As matter of fact, my foreach (working flawlessy before cache() introduction) throws: "Objects returned by Cake\ORM\Query::getIterator() must be traversable or implement interface Iterator"
# Sep 5th 2019, 13:40 g.catania Hi guys. I'm having an hard time figuring out why chaining ->cache() to my query, I can't iterate it. From docs I read "->cache() returns this, meaning a Cake\ORM\Query object".
# Sep 5th 2019, 13:39 david098 @colas.ruamps that isn't working either as clients are put multiple times in the resultset for every statement due... ->group(['Clients.id']) is also no solution as only 1 statement is left over in the resultset
# Sep 5th 2019, 13:34 alexdd55976 ok, see your point.
# Sep 5th 2019, 13:34 david098 @alexdd55976 I prefer to start from clients as i want to loop through the clients and send them an email with the request of missing statements for their contracts
# Sep 5th 2019, 13:27 colas.ruamps @david098 you could try to add `->matching('Contracts.Statements', function(....`
# Sep 5th 2019, 13:26 alexdd55976 @david098 this is my rough idea ``` $query = $this->Contracts->where(['Contracts.published'=>true]); }) ->contain('Contracts.Statements', function ($q) use ($date) { return $q ->where(['amount IS'=>NULL]) ->where(['Statements.periodend <=' => '2019-09-30']) ->order(['periodend'=>'ASC']); }) ->contain('Clients') ->order(['Clients.name'=>'ASC']); ```
# Sep 5th 2019, 13:25 neon1024 Is there a funky collection method which I could use to pick the highest value in an array of arrays?
# Sep 5th 2019, 13:23 david098 This my query at the moment, but it is returning all clients including contracts with no statements due
# Sep 5th 2019, 13:23 alexdd55976 the biggest factor seems to be contracts, so start here.. get all contracts.published, then get the statements and the clients
# Sep 5th 2019, 13:22 david098 `$query = $this->Statements->Contracts->Clients->find();` `$query` ` ->matching('Contracts', function ($q) {` ` return $q->where(['Contracts.published'=>true]);` ` })` ` ->contain('Contracts.Statements', function ($q) use ($date) {` ` return $q` ` ->where(['amount IS'=>NULL])` ` ->where(['Statements.periodend <=' => $date])` ` ->order(['periodend'=>'ASC']);` ` })` ` ->order(['Clients.name'=>'ASC']);`
# Sep 5th 2019, 13:21 alexdd55976 you could try (the obvious) to get over clients to contracts to statements.
# Sep 5th 2019, 13:21 alexdd55976 depenends from which side you comin.
# Sep 5th 2019, 13:15 slackebot will I end up doing loops and do "manual"checks?
# Sep 5th 2019, 13:15 david098 I got a querybuilder issue, I have clients who have many to many contracts what have many to many statements. I want to get all Clients with their active contracts (Contracts.published = 1) where there are statements due (Statements.periodend <= 2019-09-30). So if there is not an active contract or if there are no statements due under the contract i don't want to get the client in the resultset. Is this possible in 1 query(builder) or
# Sep 5th 2019, 13:04 leonardo.crecente actually print_r('Index'); exit;
# Sep 5th 2019, 13:03 leonardo.crecente in /httpdocs/blog/index.php I,ve put a print_r(); exit; to see if request gets there...
# Sep 5th 2019, 13:02 alexdd55976 ah.. ok.. its no subfolder shown for the cake
# Sep 5th 2019, 13:02 leonardo.crecente In any case the website url: http://www.savane.com.br and the blog url: http://www.savane.com.br/blog
# Sep 5th 2019, 12:08 spriz or at least play around with some of the existing rectors
# Sep 5th 2019, 12:09 dereuromark Once you are an expert please also contribute this to IdeHelper for better variable collection :)
# Sep 5th 2019, 12:16 ndm @val That can be achieved by setting the corresponding table class' table name so that it includes the database, like `$this->setTable('my_database.users')` instead of the default `$this->setTable('users')`.
# Sep 5th 2019, 13:01 alexdd55976 so it should be yourdomain.ltd/ and yourdomain.ltd/blog
# Sep 5th 2019, 12:59 leonardo.crecente but not success
# Sep 5th 2019, 12:59 leonardo.crecente I followed this stackoverflow post: https://stackoverflow.com/questions/55240956/wordpress-installed-in-cakephp-subfolder-on-iis-window-server
# Sep 5th 2019, 12:58 alexdd55976 should not be a problem
# Sep 5th 2019, 12:58 leonardo.crecente ON /httpdocs/app