DB_DataObject - Insert()
| From: | Barry Steele | Date: | Thu, 22 May 2003 22:49:45 +0000 |
| Subject: | DB_DataObject - Insert() | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-5561@lists.php.net to get a copy of this message | ||
Hi,
I've run into a confusing issue with DB_DataObject, and it requires a
bit of explanation.
I have number of tables (mysql) -
Beaches -- [beach_key,,,,,{cols}]
primary key = beach_key varchar(10)
car_parks [id,{cols - some are enum('y','n') ]
primary key = id int
and beach_car_park [beach_key, car_park_id]
I need to be able to deal with the case where a user is looking at
details about the beach (BTW - soon we'll have every beach in Oz on the
net in major detail)
We are in this case interested in the car_parks
The form passes the following $_POST variables :-
Output from print_r($_POST) :
Array ( [action] => insert [beach_key] => nsw209 [car_park_id] =>
[location] => blah blah [car_park_type] => sealed [sealed_parking_area]
=> N [disabled_parking] => Y [bus_parking] => N [car_park_size] => 11-50
[beach_visible] => Y [dist_to_beach] => 50 [Submit] => Submit )
In the PHP script I do :-
$carPark->setFrom($_POST);
$carPark->debugLevel(5);
then
$id = $carPark->insert();
print_r( $carPark );
print("<br> <h2> Result from insert = $id </h2> <br>");
The following result comes back
Validation OK -
Inserting new car park data
sql QUERYINSERT INTO car_parks (location , car_park_type , disabled_parking , bus_parking ,
car_park_size , beach_visible , dist_to_beach ) VALUES ('blah blah' , 'sealed' ,
0 , 0 , '11-50' , 0 , 50 )
query DONE QUERY
dataobject_car_parks Object ( [_DB_DataObject_version] => 1.0 [__table]
=> car_parks [N] => 0 [_database_dsn] => [_database_dsn_md5] =>
[_database] => absamp_test [_condition] => [_group_by] => [_order_by] =>
[_limit] => [_data_select] => * [_DB_resultid] => [_link_loaded] =>
[_join] => [_lastError] => [id] => [location] => blah blah
[car_park_type] => sealed [sealed_parking_area] => [disabled_parking] =>
Y [bus_parking] => N [car_park_size] => 11-50 [beach_visible] => Y
[dist_to_beach] => 50 )
Result from insert =
the nest step is supposed to be to insert the intersecting entity record
but as you see the insert() doesn't return the id for the new car_park.
I've also noticed that it is not inserting the correct values in the
various enumerated columns - see the insert statement.
I'm not sure what is happening.
Thanks
--
Barry Steele <barry@hpfm.biz>
hpfm