ZF-3167: pdo_mysqli describeTable primaryposition may be incorrect



CREATE TABLE test ( one varchar(10) NOT NULL default '', two varchar(10) NOT NULL default '', three tinyint(4) NOT NULL default '0', PRIMARY KEY (two,one) )

and DESCRIBE test:

Field Type Null Key Default Extra one varchar(10) NO PRI two varchar(10) NO PRI three tinyint(4) NO 0

describeTable assumes that that the column order in the primary key order matches the column order of the table ( see $primaryPosition = $p; where is the p index of key == pri from the DESCRIBE TABLE result) - A contradiction to : PRIMARY_POSITION => integer; position of column in primary key

As a result, the primary positions of the table are (one => 1, two =>2) instead of (two=>1, one=>2)

You will need to parse the CREATE TABLE to get the ordering of the columns in the primary key.


Please evaluate and fix/categorize as necessary.

We could add a ``` after DESCRIBE request to retrieve the position in 'Seq_in_index' field.

will review within 2 weeks

describeTable() returns the position in the table not in the index correct? Isn't the current behavior correct?


The current behaviour is neither correct nor useful.

{{COLUMN_POSITION}} shows the position of the field in the table.

{{PRIMARY_POSITION}} should show the position of the field in the primary key, but instead currently shows the order that primary key fields appear in the table.

Is this still an issue? Is {{describeTable}} supposed to return position of pkey fields in table or of the fields in the pkey index?

If this is an issue, can it be fixed in ZF1 at this late stage in it's lifecycle, or should it be pushed up to ZF2?

EDIT: Pastie with an example of the problem reported by OP: http://pastie.org/2580094

After consulting with [~ralph] we've decided to mark this issue as "Won't Fix" for ZF1. The implemented behavior is wrong but is well established and poses too great a risk to change at this stage in ZF1's lifecycle.