Log message #4193951

# At Username Text
# Jul 19th 2019, 12:23 adrienlambertwac Hi everyone, anybody use again Cakephp 2.x ^^ ? I want to set my primary key in the declaration of hasOne, is it possible ? In Cakephp3.x , i use the option bindingKey, but it does not work in version 2.x :(
# Jul 19th 2019, 11:30 admad @willem see the how to core shells were switched to commands in 4.0
# Jul 19th 2019, 10:53 willem question: shells are deprecated and console command is the new shell system, right. In shells i could have multiple methods per shell e.g. calculateSingle, calculateAll and call the shell with shellname calculate_all or shellname calculate_single. In commands there seems to be only one method accepted (‘execute’). So how would i mimic/create the example with two methods in a command ?
# Jul 19th 2019, 10:43 neon1024 Is it just the fixture injector listener or are there other bits which will break? I presume the cake test suite relys on the v5/v6 api of phpunit
# Jul 19th 2019, 10:43 neon1024 Can I backport PHP Unit 7 to Cake 3?
# Jul 19th 2019, 09:18 neon1024 Morning all :wave:
# Jul 19th 2019, 08:53 conehead I will have a look!
# Jul 19th 2019, 08:51 admad selecting 'Users.id' is necessary for proper related property population, else you you will also need `->enableAutoFields()`
# Jul 19th 2019, 08:50 conehead Ah I was not. That is brilliant. Thanks
# Jul 19th 2019, 08:50 admad they would select specified fields of users and all fields of profiles
# Jul 19th 2019, 08:49 admad @conehead in case you arent aware you can pass assocations to select() `$this->Users->select(['Users.name', 'Users.id'])->select($this->Users->Profiles)`
# Jul 19th 2019, 08:48 ndm no problem :slightly_smiling_face:
# Jul 19th 2019, 08:47 conehead I am sorry
# Jul 19th 2019, 08:47 conehead Valuable lesson not to strip examples anymore :(
# Jul 19th 2019, 08:46 ndm And that's why examples shouldn't be stripped down too much ;) `hasOne` will by default use a join to include the data, so your select list excludes the fields from the join, hence it won't show up. `hasMany` will use a separare query to retrieve the data, so it will ignore your select list.
# Jul 19th 2019, 08:40 slackebot $this->Articles->find()->contain(['Comments'])->select(['Articles.id, 'Articles.name, ']->first();
# Jul 19th 2019, 08:40 conehead @ndm Oh my god. I found it out thanks to your help. Although this is still a little bit confusing if you ask me. For `hasMany` (or any association containing more than one element) you do not need to select specific fields and the whole entity will show up in the property list. If the association is `hasOne`, then you will have to define the the fields you want to select. Example: ``` With hasMany:
# Jul 19th 2019, 08:25 conehead Thank you very much for this
# Jul 19th 2019, 08:25 conehead Well I think you pushed me in the right direction. Still don't know exactly what it is....but I had to test it at a different location and there it works
# Jul 19th 2019, 08:12 ndm For a `hasOne` association the property name would be `comment`, it should be there even if no associated row would exist. Maybe you have some logic in your entity, table, or in a behavior that could skew the results...
# Jul 19th 2019, 07:59 conehead `tags` property shows up fine. `comments` property does not even exist. As soon as I change `hasOne` to `hasMany` I can see the property `comments` with a value in it
# Jul 19th 2019, 07:58 conehead Ah sorry. Guess I was just a bit unclear. Usually I do not follow the naming conventions. I change the association name, so I can load the data with singular name. Works fine all the time. I just never used `hasOne` before. ``` $article = $this->Articles->find()->contain(['Comments', 'Tags'])->first(); debug($article); ```
# Jul 19th 2019, 07:52 ndm Ah no, i was referring to the property name, that's the `propertyName` setting, ie the property on the entity where the data would be placed, `comments` vs `comment`. The association name doesn't need to be changed, also the `className` option is for the association class, not the entity class ;) How do you check whether the property exists?
# Jul 19th 2019, 07:47 conehead `$this->hasMany('Comments');` returns 1 result (or empty array if none found) `$this->hasOne('Comments');` property is not even there
# Jul 19th 2019, 07:44 conehead I changed the name to `Comment` instead of `Comments` and then set the `'classname' => 'App\Model\Comment'`. But now I just changed everything not to use any settings. Still the property is just missing on the returned object
# Jul 19th 2019, 07:41 ndm Not sure what exactly you are referring to with the entity class stuff?
# Jul 19th 2019, 07:39 conehead And I tried to change the naming so it would fit without setting the className and it does not show up at all :S
# Jul 19th 2019, 07:38 conehead Ah, thanks for the explanation for the mixins. The other problem...pretty sure that this is not the problem. I have set the entity class manually
# Jul 19th 2019, 07:35 ndm @conehead Public behavior methods are mixin methods, ie methods that can be invoked via the table object that the behavior is attached to. If multiple behaviors have the same mixin method names, then it wouldn't be possible to call a specific mixin method of a specific behavior. By default the two associations are using different property names (plural vs singular), maybe that has something to do with it.
# Jul 19th 2019, 07:17 conehead And shouldn't a hasOne relation return a result, if hasMany returns a result? I just changed `hasMany` (1 result) to `hasOne` (0 results or better, the property vanishes). Questions and more questions :)
# Jul 19th 2019, 06:18 conehead Why can't different behaviors contain methods with the same name? :S
# Jul 19th 2019, 04:55 conehead @rightscoreanalysis and it probably needs to be `_ids`
# Jul 19th 2019, 04:15 justin.denick @rightscoreanalysis ids => `[`‘2’,‘1’`]` needs to be an array.
# Jul 18th 2019, 22:55 rightscoreanalysis my brain is melting... tired. Trying to save a hasMany relationship... is this not the correct format:delivery_types => [ 'ids' => '2,1' ]
# Jul 18th 2019, 21:33 grzegorek.rafal hello
# Jul 18th 2019, 18:53 joey.mukherjee Figured it out! I didn't realize Traits were a PHP thing and not a CakePHP thing. I was wondering why the docs were so sparse. Anyway, I made a new controller which included the trait and then did a return $this->profile ($id) at the end. Thanks for the help!
# Jul 18th 2019, 18:18 yamcomnet @challgren Thanks!
# Jul 18th 2019, 18:17 challgren @yamcomnet https://sandbox.dereuromark.de/export
# Jul 18th 2019, 18:10 yamcomnet Need country list phone number prefixes as array. _Just use some random gist list or is there such "official" lists somewhere?
# Jul 18th 2019, 15:03 ajibarra I am not sure what do you want to do exactly. If you can be more specific
# Jul 18th 2019, 13:54 neon1024 8)