PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject » Bug #257

Tables with multiple primary keys not handled correctly

Details

Submitted2003-11-16 08:31 UTC
Frombrat at naxs dot com
StatusNo Feedback
PackageDB_DataObject
PHP Version4.3.2
OSLinux Mandrake
Roadmaps(Not assigned)

Comments

[2003-11-16 08:31 UTC] brat at naxs dot com

Description:
------------
I have three tables, USERS, ROLE_TYPES, USER_ROLES. Abbreviated
versions follow:

CREATE TABLE users (
id integer not null auto_increment,
name varchar(40) not null,
Primary Key(id)
);

CREATE TABLE role_types (
id integer not null auto_increment,
name varchar(24) not null,
Primary Key(id)
);

INSERT INTO role_types (name) VALUES (some roles...);

CREATE TABLE user_roles (
user_id integer not null default 0,
role_type_id integer not null default 0,
Unique(user_id, role_type_id),
Foreign Key(user_id) REFERENCES users(id),
Foreign Key(role_type_id) REFERENCES role_types(id)
);

Use generate table script to create table classes...

$u = & new DO_Users;
$u->name = "JOHN";
$u->insert();

$ur = & new DO_User_roles;
$ur->user_id = $u->id;
$ur->role_type_id = 3;
$ur->insert();

USER INSERT SUCCEEDS
USER ROLE INSERT FAILS

This is the object and sql code generated (using debug). Notice
everything is set correctly in the object, but the sql insert does not
have the user_id field set.

UR=
do_user_roles Object
(
[_DB_DataObject_version] => 1.3
[__table] => user_roles
[N] => 0
[_database_dsn] =>
[_database_dsn_md5] =>
[_database] =>
[_query] => Array
(
[condition] =>
[group_by] =>
[order_by] =>
[having] =>
[limit] =>
[data_select] => *
)

[_DB_resultid] =>
[_link_loaded] =>
[_join] =>
[_lastError] =>
[user_id] => 25
[role_type_id] => 5
)

CONNECT : USING CACHED CONNECTION
QUERY : INSERT INTO user_roles (role_type_id ) VALUES ( 5 )
query : QUERY DONE IN 0.00964403152466 seconds
1 : Clearing Cache for do_user_roles


If I alter the .ini file and comment out the entire '[user_roles__keys]'
section, it works fine, but has no key information-- (which in this case
is okay since its just a glue table)


There seems to be a problem here.