DataMapper ORM v1.8.0 |
[eluser]WanWizard[/eluser]
And this doesn't? Code: $config[‘db_params’] = ""; The only different is that FALSE does Code: $this->db =& $CI->db; while TRUE ( or "" ) does: Code: $this->db = clone($CI->db);
[eluser]costicanu[/eluser]
it was $config[‘db_params’] = "" and didn't worked. Now it's $config[‘db_params’] = FALSE and works! Thanks again!
[eluser]WanWizard[/eluser]
Well, that's odd, because it's the default and it has been for years. I can not believe that cloning an object would switch a parameter setting, it seems impossible to me. What version of CI are you using, and what version of Datamapper (exactly, and installed from where)?
[eluser]JamieBarton[/eluser]
Hi guys I'm after a bit of help. I have an events site I'm wanting to view the events made by me and my friends. Friends table: id / user_id / friend_id Events table id / name / user_id How do I query for the events made by me and my friends? Can't seem to figure out where to start! Regards
[eluser]WanWizard[/eluser]
create an array with your user_id and all the user_id's of your friends. Then run a where_in() query on the events model.
[eluser]JamieBarton[/eluser]
Hi, I'm new to DataMapper.. [quote author="WanWizard" date="1339679428"]create an array with your user_id and all the user_id's of your friends. Then run a where_in() query on the events model.[/quote] Code: $friends = new Friend(); Then.. Code: $events = new Event(); Nearly there? Thanks for your help!
[eluser]WanWizard[/eluser]
You now select only your friends, but not yourself. So would add Code: $events->or_where('user_id', $this->user->id);
[eluser]jez123[/eluser]
Hi How can I include multiple columns in a join, for example the following query Code: select * from a left outer join b ON a.id = b.a_id AND b.b_id = 23; The following will create the join, but I can't work out how to add another column on the join! Code: include_related('b',array('id'),TRUE) I've really been struggling trying to work out how to do this. Thanks if you can help!
[eluser]WanWizard[/eluser]
Code: include_related('b',array('id', 'this', 'that'),TRUE) Or do you mean the join criteria (which has nothing to do with including columns)? For that, the answer is "You can't". Datamapper is an ORM, and maintains it's relations based on the PK-FK connection. Which is what is used to join two related tables. This specific example could be solved with a WHERE: Code: where_related('b', 'id', 23) Code: select * from a left outer join b ON a.id = b.a_id WHERE b.id = 23;
[eluser]jez123[/eluser]
Thanks for your help. That query is completely different from having an AND because not only of efficiency http://greensweater.wordpress.com/2008/0...onditions/ But also if you have multiple joins then including the condition in the where part of the query will return a completely different result set I'm surprised it can't be done actually, because the query restricts the result set to a specific criteria (e.g., 23 is the value of a logged in user in the session), so it should have nothing to do with foreign key constraints, and is quite commonly done in SQL. Guess I'll have to write my own function in the datamapper library or get rid of it for something less restrictive. |
Welcome Guest, Not a member yet? Register Sign In |