EllisLab text mark
Advanced Search
51 of 63
51
   
DataMapper ORM v1.8.2
Posted: 26 September 2012 08:44 AM   [ Ignore ]   [ # 751 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts

Thanks.

I have to find time to recreate this to see what goes wrong. I might have to do with the fact that you use advanced relationship definitions, it seems detection of the table alias goes wrong…

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 26 September 2012 10:27 AM   [ Ignore ]   [ # 752 ]   [ Rating: 0 ]
Joined: 2012-07-05
8 posts

I’m trying to do something like this:

// ...
$model->where_related('relative1/relative2', array('field1' => 'val1''field2' => 'val2'))->get(); 

But it doesn’t appear to support having an array for fields instead of a field and value string, as I get a db error with Array as the field name.

Is there a way to perform an advanced get with more than one field and if not, what would be a good alternative?

Thanks,
Matt

 
Posted: 26 September 2012 11:31 AM   [ Ignore ]   [ # 753 ]   [ Rating: 0 ]
Joined: 2012-01-24
23 posts

@maikens AFAIK the where_related() only accept string for field parameter.
You can find more explanation about where() and its variations from the documentation http://datamapper.wanwizard.eu/pages/getadvanced.html

But in your case, maybe you can use the following:

$model
  
->where_related('relative1/relative2''field1''val1'
  ->
where_related('relative1/relative2''field2''val2')
  ->
get(); 

Hope this helps

 
Posted: 26 September 2012 11:37 AM   [ Ignore ]   [ # 754 ]   [ Rating: 0 ]
Joined: 2012-01-24
23 posts

@WanWizard Thanks so much smile
I really do wish datamapper keeps better and better everytime.
So far, this is the easiest but powerful ORM for codeigniter I can find from google.

Really appreciate your help smile

 
Posted: 26 September 2012 11:56 AM   [ Ignore ]   [ # 755 ]   [ Rating: 0 ]
Joined: 2012-07-05
8 posts

@rick20 thanks. I ended up doing it like this:

$model->related1->get();
$model->related1->related2->where(array(('field1' => 'val1''field2' => 'val2'))->get() 

Your way seems a bit cleaner, but meh.

thanks again for the help.

 
Posted: 26 September 2012 03:38 PM   [ Ignore ]   [ # 756 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts

@rick20,

Doing my best. Problem is a severe lack of time, I’ve been on 80 hour weeks for quite some time now…

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 27 September 2012 12:49 AM   [ Ignore ]   [ # 757 ]   [ Rating: 0 ]
Joined: 2012-01-24
23 posts

thank you WanWizard, I really appreciate it.
Wow, 80 hour weeks?? Take your time, man, get some rest.
I do wish you can take a little look at my problem, but I think I can find out the alternative way meanwhile.
Just, take your time.

 
Posted: 27 September 2012 02:21 AM   [ Ignore ]   [ # 758 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts

@rick20,

Yeah, busy times. I’m designing a new datacenter for a client, I need to run my company, I’m project lead for another PHP framework, board member in another large OSS project, and then I have to find time to maintain Datamapper. And some sleep… Ah, well, you can sleep when your dead… wink

Bug found and fixed: https://bitbucket.org/wanwizard/datamapper/changeset/fb46950cc23cf07b63b97a70a0dce2953f71d58d.

Thanks for doing the debugging.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 27 September 2012 07:23 AM   [ Ignore ]   [ # 759 ]   [ Rating: 0 ]
Joined: 2012-08-13
26 posts

Just curious what’s the other php framework your a project lead for? publicly available?

 
Posted: 27 September 2012 09:59 AM   [ Ignore ]   [ # 760 ]   [ Rating: 0 ]
Joined: 2012-01-24
23 posts

Thanks a lot @WanWizard, I didnt think you will fix it so quick, thanks so much, man, I will give it a try.
And..wow…I can’t imagine even for a second, I’m in your position…got tons of responsibilities yet giving a lot of contributions to the communities, you really bring your life a priceless worth, man…
And, umm…don’t tell me you do that only for bandwidth..raspberry
I really wish you keep those great works up!
Thank you once more..

 
Posted: 27 September 2012 10:03 AM   [ Ignore ]   [ # 761 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts
CI-Newb - 27 September 2012 07:23 AM

Just curious what’s the other php framework your a project lead for? publicly available?

Let’s keep this a CodeIgniter forum, before you know it a simple question like this ends in a ‘my framework is bigger then yours’ flame war… wink

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 27 September 2012 10:05 AM   [ Ignore ]   [ # 762 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts
rick20 - 27 September 2012 09:59 AM

Thanks a lot @WanWizard, I didnt think you will fix it so quick, thanks so much, man, I will give it a try.
And..wow…I can’t imagine even for a second, I’m in your position…got tons of responsibilities yet giving a lot of contributions to the communities, you really bring your life a priceless worth, man…
And, umm…don’t tell me you do that only for bandwidth..raspberry
I really wish you keep those great works up!
Thank you once more..

No, I stopped doing it for bandwidth a long time ago, but the nick and avatar stayed.

I do it for posts like this. Thanks! smile (Oh, and because it’s fun to do…)

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 28 September 2012 03:46 PM   [ Ignore ]   [ # 763 ]   [ Rating: 0 ]
Joined: 2011-12-09
13 posts

Hello WanWizard.
I have just discovered one serious bug in self relationship model.
Here is the scenario: create absolute copy of this http://ellislab.com/forums/viewthread/196220/#923408 It wi.ll perfectly work. But if add new field named ‘organization’ (the same as model) - my local apache server will crash!
I’m sure that there is no need to fix that, but it need to be mentioned (maybe here http://datamapper.wanwizard.eu/pages/reservednames.html).

Best regards.

 Signature 

Thanks for DataMapper !!!

 
Posted: 29 September 2012 08:18 AM   [ Ignore ]   [ # 764 ]   [ Rating: 0 ]
Joined: 2012-01-22
15 posts

Hi WanWizard,


How would you formulate the query to get all objects of a specific class that don’t have a relationship with another class?

For examples, I have a class PERSON(id, firstname, lastname) that connects to EMPLOYMENT (id, start_date, end_date, person_id) which connects to COMPANY(id, company_name) using the table companies_employments(id, company_id, employment_id).

I want to be able to populate a list of all instances of PERSON that don’t have an EMPLOYMENT. (Forget about start and end_dates, I just want to see a list of person where there is no employment record for).

So in pseudo SQL : SELECT * FROM PERSON WHERE person.id NOT IN (array of all person_id in employment table)

 
Posted: 29 September 2012 05:17 PM   [ Ignore ]   [ # 765 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts
smi23 - 28 September 2012 03:46 PM

Hello WanWizard.
I have just discovered one serious bug in self relationship model.
Here is the scenario: create absolute copy of this http://ellislab.com/forums/viewthread/196220/#923408 It wi.ll perfectly work. But if add new field named ‘organization’ (the same as model) - my local apache server will crash!
I’m sure that there is no need to fix that, but it need to be mentioned (maybe here http://datamapper.wanwizard.eu/pages/reservednames.html).

I find it difficult to believe that some PHP code in a model class can crash your webserver.

And I don’t understand what you want added to the reserved names. “organisation” isn’t a reserved name.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
51 of 63
51