Log message #4124753

# At Username Text
# Mar 13th, 17:17 jojomartius looks good ;) i'm trying to do it... thanks
# Mar 13th, 17:15 cnizzardini @jojomartius https://book.cakephp.org/3.0/en/orm/query-builder.html#passing-conditions-to-contain
# Mar 13th, 17:15 cnizzardini You can do conditions on the contains
# Mar 13th, 17:13 jojomartius hey guys.. trying to play a bit with cake3's models and querys... i found in the docu a simple has many example $query = $articles->find('all')->contain(['Comments']);.. whats the best way to find only articles where the comment is cmming from a specifc user or all articels the user hasnt commented yet ;)
# Mar 13th, 17:12 dereuromark istvan: not a long term thing probably, not too performant
# Mar 13th, 17:12 cnizzardini Looks like I use removeBehavior() now?
# Mar 13th, 17:12 bakro.istvan What about views? A view which aggregates the multiple table accounts; used only for authentication
# Mar 13th, 17:11 dereuromark not sure why though
# Mar 13th, 17:11 dereuromark even earlier maybe, the behavior has to exist to be unloaded() afaik
# Mar 13th, 17:10 cnizzardini Were there any changes from 3.4 to 3.5 with loading/unloading behaviors dynamically? I am getting "Behavior class TimestampBehavior could not be found. in [vendor/cakephp/cakephp/src/ORM/BehaviorRegistry.php, line 127]" when calling $ModelName->behaviors()->unload('Timestamp');
# Mar 13th, 17:09 neon1024 @willem Then you must refactor from `belongsToMany` to `hasMany` imho
# Mar 13th, 17:08 neon1024 Oh, just one thought before I vanish. Do check DebugKit, to ensure that in the SQL tab it doesn’t say ‘An instance was created using Cake\ORM\Table’ because if it does, then you’ve probably got a typo
# Mar 13th, 17:08 willem ``` $this->belongsTo('FieldsOfStudies', [ 'foreignKey' => 'fields_of_study_id', 'joinType' => 'INNER' ]); ``` is extra in the applicantsDegreesTable, which you do not have
# Mar 13th, 17:07 willem yes that is how it is set up and it is workgin, but in the join table i have more keys to link to other tables. and i would also like to see the actual content from that table and not only the ID (which i get now)
# Mar 13th, 17:06 neon1024 Anyway, good luck. That’s the end of my day :slightly_smiling_face:
# Mar 13th, 17:06 neon1024 Perhaps it’s as simple as clearing your orm cache!?
# Mar 13th, 17:04 neon1024 So this is how you’ve got your associations setup right?
# Mar 13th, 17:04 neon1024 https://github.com/davidyell/FFBE-Helper/blob/master/src/Model/Table/SpecialisationsTable.php#L42-L44
# Mar 13th, 17:03 neon1024 https://github.com/davidyell/FFBE-Helper/blob/master/src/Model/Table/PractisesTable.php#L39-L46
# Mar 13th, 17:03 neon1024 https://github.com/davidyell/FFBE-Helper/blob/master/src/Model/Table/UnitsTable.php#L99-L101
# Mar 13th, 17:03 neon1024 Ah, bad example I’ve not normalised that :P
# Mar 13th, 17:02 neon1024 Let’s try a Unit which Practises a Specialisation
# Mar 13th, 17:02 neon1024 Perhaps a code example will help
# Mar 13th, 17:01 willem well, i think because my association in the ApplicantTable is named ‘Degree’ instead of ‘ApplicantsDegrees’ ?
# Mar 13th, 17:01 neon1024 At least, that’s how I see it
# Mar 13th, 17:01 neon1024 The problem is what your Table class associations
# Mar 13th, 17:00 neon1024 If it did, why are you getting an exception for a missing association?
# Mar 13th, 17:00 willem i understand, but when i read this and check my db and classes it looks exactly like that
# Mar 13th, 17:00 neon1024 As it’s pretty key to database design and software design
# Mar 13th, 16:59 neon1024 This is important to learn
# Mar 13th, 16:59 neon1024 I feel it’s better to teach you why than tell you what code changes to make
# Mar 13th, 16:59 willem euh kinda, but i have all those table classes already? only ``` $this->belongsToMany('Degrees', [ 'foreignKey' => 'applicant_id', 'targetForeignKey' => 'degree_id', 'joinTable' => 'applicants_degrees' ]); ``` you say this should be hasMany ?
# Mar 13th, 16:58 neon1024 Does that make sense? :slightly_smiling_face:
# Mar 13th, 16:58 neon1024 As it is associated to the two tables to normalize that many to many database relationship
# Mar 13th, 16:57 neon1024 Which is why you can see the `CoursesMembershipsTable` from the book, has two `belongsTo` associations in it
# Mar 13th, 16:57 neon1024 This is what the book page is saying
# Mar 13th, 16:57 neon1024 So when you inverse that association, you also get `ApplicantsDegrees belongsTo Applicants` in your ApplicantsDegreesTable
# Mar 13th, 16:56 neon1024 Then change the association from `belongsToMany` to `Applicants hasMany ApplicantsDegrees`
# Mar 13th, 16:56 neon1024 So you want to actually create a join table class, ApplicantsDegreesTable
# Mar 13th, 16:56 neon1024 That will allow Cake to automatically understand the join, but you need more control!
# Mar 13th, 16:56 neon1024 However