Bug #9090 [Opn->Fbk]: MySQL: Insert into a table with an identifying relationship

From: Date: Sat, 11 Nov 2006 16:44:32 +0000
Subject: Bug #9090 [Opn->Fbk]: MySQL: Insert into a table with an identifying relationship
References: 1  Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-8760@lists.php.net to get a copy of this message
Edit report at http://pear.php.net/bugs/bug.php?id=9090&edit=1 ID: 9090 Updated by: mj@php.net Reported By: pas at pas dot net dot nospam dot au -Status: Open +Status: Feedback Id: 9090 Type: Bug Package: Documentation PHP Version: Irrelevant New Comment: Which page are you referring to, please? Previous Comments: ------------------------------------------------------------------------ [2006-10-19 02:34:38] pas at pas dot net dot nospam dot au The .ini file should be: [tb_user] user_id = 129 [tb_user__keys] user_id = N [tb_user_settings] user_id = 129 [tb_user_settings__keys] user_id = K ------------------------------------------------------------------------ [2006-10-19 02:32:18] pas at pas dot net dot nospam dot au 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 this bug report at http://pear.php.net/bugs/bug.php?id=9090&edit=1

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