# |
Jun 11th 2018, 10:54 |
joopm |
maybe i am doing wrong the conditional model association |
# |
Jun 11th 2018, 10:53 |
loginews |
alright. I will go and try all this and get back here if i am stuck. |
# |
Jun 11th 2018, 10:52 |
edgaras.jan |
you can also `$this->Rep01->find()->innerJoinWith(...)`, but you would need define JOIN statement everytime. Now you define relation once in Table, and then use relation name in `contain()` |
# |
Jun 11th 2018, 10:49 |
loginews |
@edgaras.jan You see, for someone like me who has written thousands of lines of php and mysql, I am a bit surprised that it is so complex to just extract a few columns from 2 inner joined tables. |
# |
Jun 11th 2018, 10:48 |
edgaras.jan |
you need both |
# |
Jun 11th 2018, 10:48 |
loginews |
ok so I need both. |
# |
Jun 11th 2018, 10:48 |
edgaras.jan |
`contain will join another table depending on how you have configured relation using `belongsTo` |
# |
Jun 11th 2018, 10:46 |
loginews |
so I don't need belongsTo in my table model ? |
# |
Jun 11th 2018, 10:46 |
edgaras.jan |
`$query = $this->Rep01->find()->contain('saleitem');` |
# |
Jun 11th 2018, 10:45 |
edgaras.jan |
`contain()` will add JOIN |
# |
Jun 11th 2018, 10:45 |
loginews |
@edgaras.jan. I want to display some columns in cakephp via index.ctp |
# |
Jun 11th 2018, 10:44 |
loginews |
@edgaras.jan My aim is very simple. I have to SELECT * FROM psales INNER JOIN saleitem ON psales.VOUNO=saleitem.INVREF. |
# |
Jun 11th 2018, 10:44 |
edgaras.jan |
or 'saleitem', because your current code doesn't use cake convensions, so I don't know well |
# |
Jun 11th 2018, 10:43 |
edoreld |
File uploaded https://cakesf.slack.com/files/UB4FMM7H6/FB686M9AT/-.php / https://slack-files.com/T053DPNCM-FB686M9AT-ddaf04f351 |
# |
Jun 11th 2018, 10:43 |
edgaras.jan |
you need `->contain('saleitems')` in controller |
# |
Jun 11th 2018, 10:42 |
edoreld |
I created the entity in my controller but it still says 'undefined variable' :S |
# |
Jun 11th 2018, 10:42 |
loginews |
@edgaras.jan I get this: Notice (8): Trying to get property of non-object [APP/Template\Rep01\index.ctp, line 32] when I put $psale->VOUNO->ITEMNUM |
# |
Jun 11th 2018, 10:39 |
loginews |
let me try... |
# |
Jun 11th 2018, 10:39 |
edgaras.jan |
`$psale->VOUNO` is entity Saleitem, use `$psale->VOUNO->ITEMNUM` |
# |
Jun 11th 2018, 10:37 |
loginews |
File uploaded https://cakesf.slack.com/files/U435V89H8/FB4L1UJ57/learning_association.txt / https://slack-files.com/T053DPNCM-FB4L1UJ57-6c98b46968 - But the second column (i.e. ITEMNUM) does not work. |
# |
Jun 11th 2018, 10:31 |
edgaras.jan |
You can use `$category->posts`, and if you have baked entity correctly, you IDE will know it is `Post[]` and will help autocomplete rest of code |
# |
Jun 11th 2018, 10:27 |
neon1024 |
:thumbsup: |
# |
Jun 11th 2018, 10:27 |
loginews |
thanks |
# |
Jun 11th 2018, 10:27 |
loginews |
will do that |
# |
Jun 11th 2018, 10:27 |
loginews |
okay |
# |
Jun 11th 2018, 10:27 |
joopm |
:lorenzo yes the error.log is acive |
# |
Jun 11th 2018, 10:26 |
neon1024 |
If `Posts` belongs to `Categories`, there would be `$category->get('posts')` which would be an array of Post entities |
# |
Jun 11th 2018, 10:26 |
neon1024 |
@loginews Associations are a property in the Entity, either singular for singular associations and plural for plurals. |
# |
Jun 11th 2018, 10:25 |
slackebot |
!ruleone |
# |
Jun 11th 2018, 10:25 |
slackebot |
Command sent from Slack by neon1024: |
# |
Jun 11th 2018, 10:25 |
loginews |
@neon1024 You so kindly helped me with the association. I have belongsTo('subtable',['foreignKey'=>'bla', 'propertyName'=>'blabla', 'className'=>'something']). In my index.ctp I have $maintable->COL1, $maintable->COL2,.... How do I refer to something in subtable? |
# |
Jun 11th 2018, 10:22 |
lorenzo |
joomp remove the custom finder from the model definition, and do a normal find on it. Let me know if debugkit shows any warnings |
# |
Jun 11th 2018, 10:21 |
lorenzo |
joopm do you get a debugkit warning in the logs? |
# |
Jun 11th 2018, 10:15 |
joopm |
in a belongsTo association |
# |
Jun 11th 2018, 10:15 |
joopm |
i would like to use in Model's association |
# |
Jun 11th 2018, 10:14 |
adrienlambertwac |
the variable $entity is defined in your controller ? If you want to edit your $entity you can find her in your controller function and set to view form |
# |
Jun 11th 2018, 10:11 |
joopm |
make me crazy try to use in the same file but can not find |
# |
Jun 11th 2018, 10:10 |
neon1024 |
`isSuspiciouslyProduction` strikes again! ;P |
# |
Jun 11th 2018, 10:08 |
joopm |
just tried to check the debug kit, but on the error page there is no debugkit even it is allowed in the bootstrap.php |
# |
Jun 11th 2018, 10:08 |
lorenzo |
hi joopm |
# |
Jun 11th 2018, 10:05 |
joopm |
hello Lorenzo |