Bug #9090 [NEW]: MySQL: Insert into a table with an identifying relationship

From: Date: Thu, 19 Oct 2006 06:32:18 +0000
Subject: Bug #9090 [NEW]: MySQL: Insert into a table with an identifying relationship
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-8632@lists.php.net to get a copy of this message
From: pas at pas dot net dot nospam dot au Operating system: Package version: PHP version: Irrelevant Package: Documentation Bug Type: Bug Bug description: MySQL: Insert into a table with an identifying relationship Description: ------------ Lets say I have 2 tables, tb_user and tb_user_settings. Both have a primary key called 'user_id'. tb_user is the main table, and tb_user_settings is using tb_user's primary key as its own. Only tb_user.user_id is auto-incrementing, while tb_user_settings.user_id is manually inserted. When generating the configuration .ini file, the following occurs in MySQL: ---- [tb_user] user_id = 129 [tb_user__keys] user_id = N [tb_user_settings] [tb_user_settings__keys] user_id = K ---- When I call $dataobject->insert() on tb_user, the insert works fine. When I call $dataobject->insert() on tb_user_settings, I get the following error message: ---- ERROR: [db_error: message="DB Error: insufficient permissions" code=-26 mode=return level=notice prefix="" info="CREATE TABLE tb_user_settings_seq (id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) [nativecode=1142 ** CREATE command denied to user 'user'@'localhost' for table 'tb_user_settings_seq']"] ---- Changing the .ini file so to: ---- [tb_user_settings__keys] user_id = N ---- solves the problem. I have had a look in generate.php and the solution could get ugly. Test script: --------------- CREATE TABLE tb_user ( user_id Bigint UNSIGNED NOT NULL AUTO_INCREMENT, PRIMARY KEY (user_id) ) ENGINE = MyISAM; CREATE TABLE tb_user_settings ( user_id Bigint UNSIGNED NOT NULL, PRIMARY KEY (user_id) ) ENGINE = MyISAM; -- Edit bug report at http://pear.php.net/bugs/bug.php?id=9090&edit=1 --

« previous php.pear.doc (#8632) next »