Help on creation

[prev] [thread] [next] [Date index for 2005/07/05]

From: mike
Subject: Help on creation
Date: 16:53 on 05 Jul 2005
I have been looking through the documentation and writing lots and lots of code that is ugly and never seems to work. What I need to do it pretty straightforward, so I must be missing something - and I am hoping someone here can help. 

I have a Class::DBI object called booking with a has_many relationship to passengers.

I need to create the booking object and passenger objects from a cgi post with the following parameters:

| booking.date                          | 2005/7/5
| booking.departure_time                | 8:00
| booking.passenger[0].first_name       | Mike
| booking.passenger[0].surname          | McKay
| booking.passenger[1].first_name       | Claudia 
| booking.passenger[1].surname          | McKay


I would like to make some sort of data object out of this data, that I could then load directly into a Class::DBI object. I have created this:

'booking' => {
           'departure_time' => '8:00',
           'date' => '2005/7/5',
           'passenger' => [
                           {
                             'surname' => 'McKay',
                             'first_name' => 'Mike'
                           },
                           {
                             'surname' => 'McKay',
                             'first_name' => 'Claudia'
                           }
                          ],
  }

}

But there doesn't seem to be an automatic way to load this. I have to create the booking, then call add_to_passengers on it for each one of my passenger elements. This makes it awfully difficult to write generic loading code. Does anybody have any suggestions?

Thanks

Mike

Help on creation
mike 16:53 on 05 Jul 2005

RE: Help on creation
Andrew O'Brien 22:41 on 05 Jul 2005

Generated at 16:35 on 28 Jul 2005 by mariachi v0.52