Bug #9090 [Fbk->NoF]: MySQL: Insert into a table with an identifying relationship
| From: | cellog@php.net | Date: | Mon, 12 Feb 2007 20:59:39 +0000 |
| Subject: | Bug #9090 [Fbk->NoF]: MySQL: Insert into a table with an identifying relationship | ||
| References: | 1 | Groups: | php.pear.doc |
| Request: | Send a blank email to pear-doc+get-9431@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: cellog@php.net
Reported By: pas at pas dot net dot nospam dot au
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: Documentation
PHP Version: Irrelevant
Previous Comments:
------------------------------------------------------------------------
[2006-11-11 11:44:32] mj at php dot net
Which page are you referring to, please?
------------------------------------------------------------------------
[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