DataMapper ORM v1.8.2 |
[eluser]WanWizard[/eluser]
[quote author="Maglok" date="1348481921"]Class Organisation has many Class CCClass Class CCClass has many Class Feature I want the features that CCClass has to be limited to the features denoted by the count column in class Level.[/quote] How does CCClass relate to Level? That isn't mentioned anywhere.
[eluser]WanWizard[/eluser]
@rick20, Try to avoid iterating over a resultset, as that will produce N+1 queries. Instead, select all departments, and then run a where_in($departments) query, it will use the id's of the resultset to select all records related to those departments.
[eluser]rick20[/eluser]
@WanWizard ah..thanks for the correction But I thought before get() is called, there's no query executed, isn't it? (CMIIW). And yeah, I just realized that we can use where_in($departments). Thanks for the advice Btw, do you have any idea with my issue here: http://ellislab.com/forums/viewthread/20...0/#1031471 Kindly advice. Thanks
[eluser]matyhaty[/eluser]
@WanWizard @rick21 Thanks for that - which worked, by doing the following: Code: $dd = new Department(); Do you have to specify a column to use (not a problem, as I have state for all tables, just wondering.... However when changing them together - it didn't seem to work I made up a little example, which is fairly long handed written: Code: public function tester() which produces the following output: Code: Departments Checker I was expecting the only resulting task to be task ID 84, as that is both related to a depot and department Any ideas? Thanks
[eluser]WanWizard[/eluser]
[quote author="Maglok" date="1348555964"]Level = Organisation, apologies.[/quote] Ah, ok. Sounds a bit similar to the other "question of the day". I think I would something like Code: $ccclass = new CCClass();
[eluser]WanWizard[/eluser]
@matyhaty, A "SELECT * FROM table WHERE id IN (x,y,z)" is always an OR, not an AND.
[eluser]matyhaty[/eluser]
Is there a way of doing an AND, or some sort of merge on two seperate result sets (even if that result set is just a load of ID's that would do!)
[eluser]Maglok[/eluser]
It does seem to be the question of the day I just wondered if it was possible to do a relationship between the two that is a 'simple' has_many or has_one and does not require me to change the getting of the class. Regardless this does anwser the question and I'll just stick with the functions that do what you are suggesting for me. Keep up the good work wizard!
[eluser]rick20[/eluser]
@WanWizard do you have any suggestion of how to select rows from a table that have many-to-many relationship with other table, filtered by a field in join-table? You can refer to this post for the codes http://ellislab.com/forums/viewthread/20...0/#1031471 So far I already tried the followings with no luck: Code: $user = new User(1); Really need help. Thanks |
Welcome Guest, Not a member yet? Register Sign In |