EllisLab text mark
Advanced Search
53 of 63
53
   
DataMapper ORM v1.8.2
Posted: 25 October 2012 05:05 PM   [ Ignore ]   [ # 791 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts

No, all foreign keys are required to have the suffix ‘_id’.

It’s hardcoded, and very complex to change (which is why it hasn’t happened yet).

 Signature 

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

 
Posted: 26 October 2012 05:26 AM   [ Ignore ]   [ # 792 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-12
420 posts

But it might in 2.0!... Right? smile

 Signature 

- Simon

 
Posted: 26 October 2012 07:03 AM   [ Ignore ]   [ # 793 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts

It’s at the top of the todo list, yes.

 Signature 

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

 
Posted: 03 November 2012 10:18 PM   [ Ignore ]   [ # 794 ]   [ Rating: 0 ]
Joined: 2011-05-18
15 posts

Humm i´m new at Datamapper ORM, and im just reading all the documentation and trying some snnipets… But now this come to my mind…. If your are no longer mantaining HTML Form, how should i generate forms based on the models… i dont get it very well.

Thank you in advanced

 
Posted: 04 November 2012 06:53 AM   [ Ignore ]   [ # 795 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts

Easy answer is: like you would make a form otherwise.

Having said that, there’s nothing wrong with the form extension, it works fine, check the included example application.

 Signature 

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

 
Posted: 04 November 2012 12:23 PM   [ Ignore ]   [ # 796 ]   [ Rating: 0 ]
Joined: 2011-05-18
15 posts

OK. Thank you for your answer….

Humm but the extension will work for any future release of DMO?

 
Posted: 04 November 2012 06:58 PM   [ Ignore ]   [ # 797 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts

No guarantees, I only don’t make any promisses towards maintaining it.

I don’t write (new) CI applications anymore, and I haven’t used the extension in years. But the DM code is very stable, and as CI itself hardly changes, there isn’t much to maintain, and I don’t see it breaking any time soon. Unless CI 3 is going to “pull a kohana”, but I don’t think so…

 Signature 

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

 
Posted: 05 November 2012 10:32 AM   [ Ignore ]   [ # 798 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-12
420 posts

Pull a Kohana hm? Lets hope not. smile

It’s a shame you don’t write new CI apps anymore, why not!

I myself am up to the point where I want to use related queries. It’s still a bit iffy in my head:

Imagine a object Person and a object Car. A Person can have a Car. A Car can have some Wheel objects. The thing is I want to related the Wheel objects specifically to the Person.

In example: Bob buys a Ford. The Ford has four objects of ‘Fancy Wheels’. That is Bob’s Ford, not everyone else’s.

Am I right to assume I have to relate that by get_by_related somehow? If so the pages on related stuff, I don’t seem to quite get. Can anyone enlighten the subject to me through this example?

 Signature 

- Simon

 
Posted: 05 November 2012 11:03 AM   [ Ignore ]   [ # 799 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts

The why has been discussed in the past.

You need to pick the right tools for the job, and CI just wasn’t (anymore). I was sick and tired bolting lots of stuff on, and extending most of the core classes, to make it into what I needed. Applications became fat, slow and bloated.

Having said that CI still is the right tool for a lot of jobs for a lot of people. Which is why I still maintain DM. It’s just not for me anymore.

As to your question: in this case “Wheels” is a property of the relation between Bob and His Ford. Assuming that you currently have a many-to-many between Person and Car, I would convert this to two one-to-many’s, which a separate model for the join table (CarOwner). You can then relate all kinds of stuff to the Carowner model.

 Signature 

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

 
Posted: 05 November 2012 11:27 AM   [ Ignore ]   [ # 800 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-12
420 posts

I can’t say I follow.

Wheels do need to know whose Car it is they are attached to, but I don’t see how a CarOwner model would be any different then a Person. And a separate model for the join table?

Lets talk database:

person: ID, [stuff]
car: ID, [stuff]
wheel: ID, [stuff]
join_person_car: ID, person_id, car_id
join_car_wheel: ID, car_id, wheel_id, person_id?

That is what I had in mind so far, but unsure how to do that with datamapper.

 Signature 

- Simon

 
Posted: 05 November 2012 03:22 PM   [ Ignore ]   [ # 801 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts

No, that’s not what I meant.

You currently have: Person -> has_many -> (via join_person_car) <- has_many <- Car (a many-many between Car and Person).

If Wheel is something specific about the combination of a car and a person, from a normalisation point of view it should be related to the join table, and not to either Person or Car.

This means you have to make a model for the join table (let’s call that PersonCar), otherwise you can’t relate something to it.

You now get:
- Person -> has_many - <- has_one <- PersonCar
- Car -> has_many - <- has_one <- PersonCar

This will still be a many to many between Person and Car. If you define a custom tablename of ‘join_person_car’ for the PersonCar model, you don’t even have to change the many to many for direct access via Person or Car.

Now that you have this, you can relate other models of PersonCar:
- PersonCar -> has_one -> Wheel (which has wheel_id in PersonCar)

 Signature 

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

 
Posted: 06 November 2012 12:09 AM   [ Ignore ]   [ # 802 ]   [ Rating: 0 ]
Joined: 2011-05-18
15 posts
WanWizard - 04 November 2012 06:58 PM

No guarantees, I only don’t make any promisses towards maintaining it.

I don’t write (new) CI applications anymore, and I haven’t used the extension in years. But the DM code is very stable, and as CI itself hardly changes, there isn’t much to maintain, and I don’t see it breaking any time soon. Unless CI 3 is going to “pull a kohana”, but I don’t think so…

:( But i´m not very clear… you will keep DM ORM mantained?

Abot what you said… you dont prefer CI anymore, what do you recommend us then?

 
Posted: 06 November 2012 03:46 AM   [ Ignore ]   [ # 803 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4405 posts

Yes, I will.

I can’t recommend anything. You choose the right tool for the job. For me, that wasn’t CI anymore.

 Signature 

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

 
Posted: 09 November 2012 03:07 AM   [ Ignore ]   [ # 804 ]   [ Rating: 0 ]
Joined: 2012-08-13
26 posts

Hello, I’m using the login example listed on the datamapper website. What I’m trying to build now is a function to allow users to change their password. I want the user to input their current password before allowing a new password to be saved. Simply saving a new password for the user works fine:

$u->password $this->input->post('newpassword')
$u->save(); 

how would I go about doing this:

if ($u->password == $this->input->post('currentpassword')
{
$u
->password $this->input->post('newpassword')
$u->save();

obviously the above will not work because it’s comparing a plaintext password against something already encrypted… thoughts?

 
Posted: 09 November 2012 03:30 AM   [ Ignore ]   [ # 805 ]   [ Rating: 0 ]
Avatar
Joined: 2009-06-12
420 posts

Encrypt it before comparing it. I can’t recall the encryption the example uses, but something like this:

if($u->password == encrypt($this->input->post('currentpassword')) 
 Signature 

- Simon

 
53 of 63
53