Log message #4264699

# At Username Text
# Jun 3rd 2021, 08:58 etibor thank you @philo.hamel okey, first please tell me how can i insert a whole code block not just one line here
# Jun 3rd 2021, 08:55 philo.hamel you'll need conditions to figure out which row to fetch for the association
# Jun 3rd 2021, 08:54 slackebot ->setProperty('work_address') ->setConditions(['WorkAddress.label' => 'Work']) ->setDependent(true); } }```
# Jun 3rd 2021, 08:54 philo.hamel ```class UsersTable extends Table { public function initialize(array $config): void { $this->hasOne('HomeAddress', [ 'className' => 'Addresses' ]) ->setProperty('home_address') ->setConditions(['HomeAddress.label' => 'Home']) ->setDependent(true); $this->hasOne('WorkAddress', [ 'className' => 'Addresses' ])
# Jun 3rd 2021, 08:54 philo.hamel @etibor have you seen this example?
# Jun 3rd 2021, 08:26 etibor or is this not possible without the Documents table have an last_file_id db field??
# Jun 3rd 2021, 08:23 etibor so without the [0] index i would like to get
# Jun 3rd 2021, 08:22 etibor i do this becuase i would like to get the last inserted url_files record and not reach like $last_model[0]->url_path // this is the only working solution now
# Jun 3rd 2021, 08:21 etibor `$this->hasMany('UrlFiles', [` `'className'=>'UrlFiles',` and `$this->hasOne('UrlFiles', [` `'className'=>'LastUrlFiles',` the LastUrlFiles Model does not load in the contain
# Jun 3rd 2021, 08:20 etibor but it does not work
# Jun 3rd 2021, 08:20 etibor i would like to make another association to the same model, the first is a HasMayn while the second is a HasOne
# Jun 3rd 2021, 08:19 etibor hello everyone
# Jun 3rd 2021, 07:07 paolo.bragagni there is a better way?
# Jun 3rd 2021, 07:07 paolo.bragagni in my old template with cake2 I rewrote the beforeFind in model where I tranformed fields in Ita
# Jun 3rd 2021, 07:05 paolo.bragagni How to search between date with https://github.com/FriendsOfCake/search ? and how to set date and numbers in italian (I mean dd/gg/YYYY) in search plugin?
# Jun 3rd 2021, 04:57 y.teruyacookie @ndm Thank you very much! I thought it is the problem about memory overload. Simply I make a mistake about how to use finder method. I have solved this problem finally. Thank you very much!!
# Jun 3rd 2021, 00:47 slackebot for each of your `Documents` results.
# Jun 3rd 2021, 00:47 slackebot https://stackoverflow.com/questions/30241975/how-to-limit-contained-associations-per-record-group/30270675#30270675, for single results you can possibly hack something in using association conditions. Other than that you don't have too many options, the next best thing would then be to manually load and inject the associated results in a result formatter, either using similar partitionable windows, or god forbid, by issuing one query
# Jun 3rd 2021, 00:47 ndm @etibor Because limiting associations isn't supported out of the box. `hasMany` and `belongsToMany` associations are being retrieved in _one_ separate query, so if you apply a limit to it, that query will only receive one record for _all_ your `Documents`, not for _each one_ of them. Try https://github.com/icings/partitionable/, or have a look at the examples in
# Jun 2nd 2021, 22:42 etibor why i can not get only one element from the associated Model: `'PrivateThesises.PrivateThesisUrlFiles' => function($q) {` `$q` `->where(['Documents.class'=>'Types'])` `->order('UrlFiles.created ASC')` `->limit(1)` `;` `return $q;//->first() or last() does not works` `},`
# Jun 2nd 2021, 22:25 ndm tumbleweed
# Jun 2nd 2021, 22:05 etibor hello everyone
# Jun 2nd 2021, 15:50 duchdamian thanks for your help, have a good day!
# Jun 2nd 2021, 15:49 slackebot '/var/www/html/src'`
# Jun 2nd 2021, 15:49 duchdamian oh I see what's up, so the --config it's pulling into rector is actually a php file and not a yaml file, the following command worked if I point it to the yaml directly. It's an issue with the upgrade tool I believe `/cake_upgrade/vendor/bin/rector process --autoload-file='/var/www/html/vendor/autoload.php' *--config='/cake_upgrade/vendor/rector/rector/config/set/cakephp/cakephp40.yaml'* --working-dir='/var/www/html/src'
# Jun 2nd 2021, 15:47 kevin.pfeifer yea, i mean just skip rector
# Jun 2nd 2021, 15:47 duchdamian that error comes from rector not cake and I do have all logging enabled
# Jun 2nd 2021, 15:46 kevin.pfeifer @duchdamian I have heard of many times where the rector upgrade tool was pretty finicky to setup I would just perform the "pure" composer update, set the ```'Error' => [ 'errorLevel' => E_ALL, ]``` and go from one error to the next
# Jun 2nd 2021, 15:44 duchdamian CakePHP upgrade tool (master) https://github.com/cakephp/upgrade CakePHP skeleton app (3.x) https://github.com/cakephp/app/tree/3.x Followed the 4.0 upgrade guide (https://book.cakephp.org/4/en/appendices/4-0-upgrade-guide.html)
# Jun 2nd 2021, 15:43 kevin.pfeifer https://github.com/FriendsOfCake/awesome-cakephp#auditing--logging
# Jun 2nd 2021, 15:42 slackebot ~tell iquana about awesome
# Jun 2nd 2021, 15:42 slackebot Command sent from Slack by kevin.pfeifer:
# Jun 2nd 2021, 15:39 thomas078 need to do audit trail tool. Is there a proper plugin or just to write myself?
# Jun 2nd 2021, 15:12 slackebot '/var/www/html/src' [ERROR] Mapping values are not allowed in multi-line blocks in "/cake_upgrade/config/rector/cakephp40.php" at line 1 (near "<?php"). Rector applied successfully```
# Jun 2nd 2021, 15:12 slackebot bin/cake upgrade rector --rules cakephp40 /var/www/html/src -v Detecting autoload file for /var/www/html/src -> Checking /var/www/html/src/vendor/autoload.php -> Checking /var/www/html/vendor/autoload.php -> Found /var/www/html/vendor/autoload.php Running /cake_upgrade/vendor/bin/rector process --autoload-file='/var/www/html/vendor/autoload.php' --config='/cake_upgrade/config/rector/cakephp40.php' --working-dir='/var/www/html/src'
# Jun 2nd 2021, 15:12 duchdamian Hi everyone - I'm in beginning stages of converting an app from cake 3.x to 4.x and the cake upgrade tool (rector) returns an error what sounds to me like a yaml parsing error. I'm not sure if that's a right place to post this but if someone ran into this before or knows what the issue might be I could really use some help. Also getting the exact same results against 3.9 skeleton app. CLI running PHP 7.4 ```bash-5.0#
# Jun 2nd 2021, 15:10 ndm https://book.cakephp.org/4/en/orm/retrieving-data-and-resultsets.html#custom-finder-methods
# Jun 2nd 2021, 15:09 ndm @y.teruyacookie That's not how the `find()` method works, it only take two arguments, the first being the finder name, and the second being an array of options. Similarly finder methods also only take two arguments, the first being the query object, the second being the options array.
# Jun 2nd 2021, 14:58 slackebot ->where(function (QueryExpression $exp) use { return $exp->between('Models.created', '2021-04-01 00:00:00', '2021-04-10 00:00:00'); }) ->order([ 'Models.created' => 'ASC' ]) ->find('Contain'); }```
# Jun 2nd 2021, 14:58 slackebot index() { // output JSON file return $this->setDatas($begin, $end); } public function setDatas($begin, $end) { $datas = $this->Model->find('Datas'); $spreadSheets = $this->Component->toSpreadSheetDatas($datas); return $this->response->withType('application/json') ->withStringBody(json_encode($spreadSheets)); } src/Model/Table/ModelTable.php public function findDatas(Query $query) { return $query ->find('Fields')
# Jun 2nd 2021, 14:58 slackebot select the fields (columns) we want from the table with the select method ->where(function (QueryExpression $exp) use ($begin, $end) { return $exp->between('Models.created', $begin, $end); }) ->order([ 'Models.created' => 'ASC' ]) ->find('Contain'); // Use contain method to join other tables as needed }``` `Code that does not cause memory overload` src/Controller/Api/Controller.php ```public function