PEAR is archived and read-only

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

Home » Authentication » LiveUser_Admin » Bug #4348

All addSomething methods return 1 instead of the new ID when used with MDB2

Details

Submitted2005-05-15 03:20 UTC
Fromscragz at hotmail dot com
StatusBogus
PackageLiveUser_Admin
PHP Version4.3.10
OSirrelevant
Roadmaps(Not assigned)

Comments

[2005-05-15 03:20 UTC] scragz at hotmail dot com

Description:
------------
Going by the examples, it looks like the addSomething (addArea, addRight, etc.) methods are supposed to be returning an ID. I know that they used to do this correctly when I was using an earlier version and DB instead of MDB2 because I have a bunch of code that doesn't work anymore. Now, however, they only return the number of affected rows, which is always one.

Reproduce code:
---------------
Run the examples.

Expected result:
----------------
string(170) query: SELECT liveuser_areas.area_id AS area_id, liveuser_areas.application_id AS application_id, liveuser_areas.area_define_name AS area_define_name
FROM liveuser_areas

string(63) query: INSERT INTO liveuser_rights_seq (sequence) VALUES (NULL)

string(101) query: CREATE TABLE liveuser_rights_seq(sequence INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (sequence))

string(60) query: INSERT INTO liveuser_rights_seq (sequence) VALUES (1)

string(108) query: INSERT INTO liveuser_rights
(area_id, right_define_name, right_id)
VALUES (1, 'RIGHT_1_537822891', 1)

Created Right Id 1

string(63) query: INSERT INTO liveuser_rights_seq (sequence) VALUES (NULL)

string(30) query: SELECT LAST_INSERT_ID()

string(57) query: DELETE FROM liveuser_rights_seq WHERE sequence < 2

string(109) query: INSERT INTO liveuser_rights
(area_id, right_define_name, right_id)
VALUES (1, 'RIGHT_1_2118218732', 2)

Created Right Id 2

string(63) query: INSERT INTO liveuser_rights_seq (sequence) VALUES (NULL)

string(30) query: SELECT LAST_INSERT_ID()

string(57) query: DELETE FROM liveuser_rights_seq WHERE sequence < 3

string(109) query: INSERT INTO liveuser_rights
(area_id, right_define_name, right_id)
VALUES (1, 'RIGHT_1_1659353554', 3)

Created Right Id 3

Actual result:
--------------
string(170) query: SELECT liveuser_areas.area_id AS area_id, liveuser_areas.application_id AS application_id, liveuser_areas.area_define_name AS area_define_name
FROM liveuser_areas

string(63) query: INSERT INTO liveuser_rights_seq (sequence) VALUES (NULL)

string(101) query: CREATE TABLE liveuser_rights_seq(sequence INT NOT NULL AUTO_INCREMENT, PRIMARY KEY (sequence))

string(60) query: INSERT INTO liveuser_rights_seq (sequence) VALUES (1)

string(108) query: INSERT INTO liveuser_rights
(area_id, right_define_name, right_id)
VALUES (1, 'RIGHT_1_537822891', 1)

Created Right Id 1

string(63) query: INSERT INTO liveuser_rights_seq (sequence) VALUES (NULL)

string(30) query: SELECT LAST_INSERT_ID()

string(57) query: DELETE FROM liveuser_rights_seq WHERE sequence < 2

string(109) query: INSERT INTO liveuser_rights
(area_id, right_define_name, right_id)
VALUES (1, 'RIGHT_1_2118218732', 2)

Created Right Id 1

string(63) query: INSERT INTO liveuser_rights_seq (sequence) VALUES (NULL)

string(30) query: SELECT LAST_INSERT_ID()

string(57) query: DELETE FROM liveuser_rights_seq WHERE sequence < 3

string(109) query: INSERT INTO liveuser_rights
(area_id, right_define_name, right_id)
VALUES (1, 'RIGHT_1_1659353554', 3)

Created Right Id 1

[2005-05-15 23:23 UTC] smith at backendmedia dot com

I think I found the bug. Are you using force_seq => false? In that case you need to modify line 188 from:
if ($sequence_field) {

to

if ($sequence_field !== false) {

I will fix the bug once I leave Cancun :-)

[2005-05-16 10:05 UTC] scragz at hotmail dot com

Sorry, I think this is another bogus bug as the examples work after a CVS pull.

I'm attempting to use LiveUser to its full potential, and a lot of little stuff changed since 0.13.x (plus the documentation problem, but you know that already), so I'm not sure what is a bug or what I just need to update in my code. Switching to MDB2 from DB is only making things more complicated.