PHPDS_query keyField=__auto__ causes primary key headaches
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
PHPDevShell |
Fix Released
|
High
|
TitanKing |
Bug Description
By default a query is assumed to make the array key the id of the primary key field. This caused problems with other developers before as it assumes that the primary field will be unique and auto-incremented. I think the logic behind this is very limited and will in the future cause other potential bugs. The current bug I am battling is this:
Assuming we dont have an id field and only have to key field, something like this:
CREATE TABLE `pds_core_
`user_role_id` int(10) NOT NULL DEFAULT '0',
`menu_id` varchar(32) NOT NULL,
PRIMARY KEY (`user_
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Assuming we add values like these,
INSERT INTO pds_core_
INSERT INTO pds_core_
INSERT INTO pds_core_
INSERT INTO pds_core_
INSERT INTO pds_core_
INSERT INTO pds_core_
INSERT INTO pds_core_
Now the system will only return a single row when queried as __auto__ assumed incorrectly. It basicly assigned 1 as the key array field hence overriding it every time.
description: | updated |
Changed in phpdevshell: | |
status: | New → In Progress |
importance: | Undecided → High |
assignee: | nobody → TitanKing (titan-phpdevshell) |
milestone: | none → 3.1.3-stable |
description: | updated |
Changed in phpdevshell: | |
status: | In Progress → Fix Released |
I noted just now that passing protected $keyField = ''; solves this problem by building array normally. Going to leave this bug open until I document this.