The aim being to print a table of recipes, each with its primary ingredient and associated ingredient type. Then, I can design a new menu by choosing a recipe according to the specific ingredient (or ingredient type) I want to use at the time. (In the future, this will be a jQuery lookup routine, but for now Iām just trying to get my app working from start to finish).
Cake outputs an SQL error:
Column not found: 1054 Unknown column āIngredients.nameā in āfield listā
If I remove the select statement, the query runs fine, but it gives me all the columns from all three tables.
The docs led me to believe the query Iām trying to assemble should be easily supported.
Well. It seems inserting a new entity with new associated data is also not supported ā also despite being prominently stated in the docs.
And now for a rant:
āWith a refreshed application skeleton design, CakePHP 4.0.0 comes with a streamlined API making your development and application faster.ā ā CakePHP.org
Categorically, sadly: ānoā.
This platform has, above all else, maintained a talent for being as frustrating as it is helpful. I had hoped that with version 4 this kind of insanity would be ended. Is it the documentationā¦or the platform? I believe itās the former and always has been.
'It just works" has rarely been an applicable phrase for any new release of CakePHP. Sure, for a simple blog, as has been the customary tutorial in every single version of the docs, it does an ok job. Even though I canāt count how many inconsistencies between the docs and the tutorials Iāve encountered over the years. Even as the blog tutorial sidesteps and glosses over any remotely robust UX/UI experience or user/access control paradigm or slightly complex data schema.
I may have to fall back to 3.9. Presumably that version should be working correctly. The last version I used with any degree of success was 3.2 a few years back.
Maybe I expect too much of it. It is free after all. I guess the company backing this project has a vested interest in the platform being just hampered enough to attract consulting/support clients.
Has anyone out there, not involved with the project, actually built a complex, data-driven application using 4.x?
Ingredients is presumably a belongsToMany relationship, so it doesnāt do a join to that table, but rather a second query. Hence why the field youāre trying to select isnāt available. Does putting it on the contain level work?
Iāve had my share of rants. Iāve built a fairly large site on CakePHP 2 and to be honest, I was very happy with it. Iāve been able to achieve everything Iāve needed to achieve. Iāve become so comfortable with it, I donāt feel like thereās anything I canāt accomplish. APIās, complex data structures, etc. With version 2 loosing support though, Iām trying to upgrade to version 4. Itās been painful to say the least. Iāve come into it not really knowing anything about version 3 or 4. Itās coming along, but not without some serious headaches. In some cases it seems like things have been made more complicated rather than simple. Itās turned into a complete rewrite of the whole application without any method going untouched.
I have given up on trying to get the data to save elegantly in a āCakeā way.
Instead, Iām simply assembling each nested entity by hand in the controllerā¦ and saving each, one by oneā¦ after obtaining the id from the one saved before.
In 20 minutes I got this working ā after spending 2 whole days trying to make it work the Cake way.
And the fact is, I realize now that I never did manage to get nested inserts to work ā not even back on Cake 2.0. I thought I had done it in 3.2, but it turns out that project didnāt have nested inserts. The last time I had to make a series of nested inserts, I had to break it up and do one by one back then too.
So much for the example in the docs. I have NEVER seen it working.
FWIW, Iāve tried debugging my top entity after patchEntity and before calling save andā¦ plain as day, itās totally, utterly, pretending none of my other entities even exist. Just dropping them. Not even a note to tell me. It just ignores their existence. Even when I try to build the entire tree manually beforehand. Even if I turn off validation in patchEntity.
I do it all the time. I donāt know why itās not working for you. If you can read the entity structure that you want from pre-existing records, then just replicate that in the way you name your fields.