Issues

ZF-5907: _setupPrimaryKey: array_intersect incorrect

Issue Type: Bug Created: 2009-02-27T06:33:32.000+0000 Last Updated: 2010-11-20T21:34:16.000+0000 Status: Resolved Fix version(s): Reporter: Marc van de Geijn (bhosted) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db_Table

Related issues: Attachments:

Description

Since version 1.7.0 I get the error on row 772 of Zend/Db/Table/Abstract.php. When debugging I see that the array_intersect parameters can never get a positive result:

$cols is an array with the following content:

<pre class="highlight">
Array
(
    [account_id] => Array
        (
            [SCHEMA_NAME] => 
            [TABLE_NAME] => account
            [COLUMN_NAME] => account_id
            [COLUMN_POSITION] => 1
            [DATA_TYPE] => bigint
            [DEFAULT] => 
            [NULLABLE] => 
            [LENGTH] => 
            [SCALE] => 
            [PRECISION] => 
            [UNSIGNED] => 1
            [PRIMARY] => 1
            [PRIMARY_POSITION] => 1
            [IDENTITY] => 1
        )

    [accounttype_id] => Array
        (
            [SCHEMA_NAME] => 
            [TABLE_NAME] => account
            [COLUMN_NAME] => accounttype_id
            [COLUMN_POSITION] => 2
            [DATA_TYPE] => bigint
            [DEFAULT] => 1
            [NULLABLE] => 
            [LENGTH] => 
            [SCALE] => 
            [PRECISION] => 
            [UNSIGNED] => 
            [PRIMARY] => 
            [PRIMARY_POSITION] => 
            [IDENTITY] => 
        )
       ....

$this->_primary contains an array with the following content:

<pre class="highlight">
Array
(
    [1] => account_id
)

Can somebody please confirm this is a bug?

Comments

Posted by Marc van de Geijn (bhosted) on 2009-02-27T06:51:10.000+0000

I've created a workaround for this issue:

monospaced } else if (isset($this->_primary[0])) { array_unshift($this->_primary, null); unset($this->_primary[0]); }

    $cols = $this->_getCols();

    foreach( (array) $this->_primary as $column ) {
        if( ! array_key_exists( $column, $cols ) ) {
            require_once 'Zend/Db/Table/Exception.php';
            throw new Zend_Db_Table_Exception("Primary key column(s) ("
                . implode(',', (array) $this->_primary)
                . ") are not columns in this table ("
                . implode(',', $cols)
                . ")");
        }
    }

    $primary    = (array) $this->_primary;
    $pkIdentity = $primary[(int) $this->_identity];

Posted by Marc van de Geijn (bhosted) on 2009-03-11T01:56:20.000+0000

After more debugging I found out that this was not in issue in the Framework, but in my own code. Unfortunatly, I can not find an option to close this issue myself.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts