Hi

Im trying to run two loops in one of my scripts to insert information
into my database and running into the same problem for both of them.
The info inserts into the database exactly as I would expect, but on
my view it throws me the errors below, and I cant figure out why
because I dont see why it should be trying to do that particular query
- I havent asked it to (so far as I know, but I'm a noob and I still
dont really get cake...)

My databases are a carry on from a previous system and not exactly
classically named:  eg: my primary key for one is 'db_id' and the
other is 'b_id' rather than them both just being 'id'.

In this particular example i have three inserts/saves in my loop, and
the error is only thrown for the first two 'bookings'.  If I change my
database naming, so 'b_id' is now just 'id', then I dont get any
errors, but only the last (third) booking is inserted into the
database.

Does anyone know how to solve this problem?  Or at the very least hide
the errors in my view?

Im hoping cake will make my life easier in the long run, but so far
its taken me a week to do something that would have taken me less than
a day in native PHP!!!

The Errors eg:

Query: SELECT COUNT(id) AS count FROM `bookings` WHERE `id` = 42
Warning: SQL Error: 1054: Unknown column 'id' in 'field list' in G:
\WAMP\www\UASC Sourceforge\trunk\cake\libs\model\datasources
\dbo_source.php on line 440

Query: SELECT COUNT(id) AS count FROM `bookings` WHERE `id` = 43
Warning: SQL Error: 1054: Unknown column 'id' in 'field list' in G:
\WAMP\www\UASC Sourceforge\trunk\cake\libs\model\datasources
\dbo_source.php on line 440

The foreach loop:

foreach($this->data['Booking'] as $theBooking){
        $theBooking['b_created_at'] = date("Y-m-d H:i:s");
        $theBooking['b_booking_group_id'] = $booking_group_id;
        $this->Booking->save($theBooking);
}

$this->data['Booking'] is an array that comes from my form on the
previous page, eg:

<input type="hidden" name="data[Booking][1][b_name]"  value="<? echo
$members['Member']['first_name'] . " " . $members['Member']
['last_name']; ?>" />
                        <input type="hidden" 
name="data[Booking][1][b_contact_phone]"
value="<? echo $members['Member']['phone']; ?>" />
                        <input type="hidden" 
name="data[Booking][1][b_member_no]"
value="<? echo $members['Member']['id']; ?>" />
                        <input type="hidden" 
name="data[Booking][1][b_member_group]"
value="<? echo $members['Member']['member_group_id']; ?>" />
                        <input type="hidden" 
name="data[Booking][1][b_is_contact_person]"
value="1" />







--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to