Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Changed self::SPECIFICATION_* to static::SPECIFICATION_* in non declarat... #4907

Merged
merged 3 commits into from
Oct 21, 2013
Merged

Changed self::SPECIFICATION_* to static::SPECIFICATION_* in non declarat... #4907

merged 3 commits into from
Oct 21, 2013

Conversation

corentin-larose
Copy link
Contributor

This patch allow to extend \Zend\Db\Sql\Delete|Insert|Update classes in order to very easily implement driver specific syntaxes like the MySql REPLACE, INSERT IGNORE or INSERT ON DUPLICATE KEY UPDATE etc.

For example :

<?php
namespace Qapa\Db\Sql\Mysql;

class Replace extends \Zend\Db\Sql\Insert
{
    /**#@+
     * Constants
     *
     * @const
     */
    const SPECIFICATION_INSERT = 'replace';
    /**#@-*/

    /**
     * @var array Specification array
     */
    protected $specifications = array(
        self::SPECIFICATION_INSERT => 'REPLACE INTO %1$s (%2$s) VALUES (%3$s)'
    );
}

or

<?php
namespace Qapa\Db\Sql\Mysql;

class InsertIgnore extends \Zend\Db\Sql\Insert
{
    /**#@+
     * Constants
     *
     * @const
     */
    const SPECIFICATION_INSERT = 'insertIgnore';
    /**#@-*/

    /**
     * @var array Specification array
     */
    protected $specifications = array(
        self::SPECIFICATION_INSERT => 'INSERT IGNORE INTO %1$s (%2$s) VALUES (%3$s)'
    );
}

If agreed, I will add unit tests.

…rative lines in order to allow override when extending
@weierophinney
Copy link
Member

@corentin-larose Looks reasonable -- please add unit tests, and we can merge. :)

@corentin-larose
Copy link
Contributor Author

Ok, not really sure what I'm going to test yet but I gonna take a look to this.

@corentin-larose
Copy link
Contributor Author

@weierophinney should be ok/compliant if you want to merge

@ghost ghost assigned Maks3w Oct 21, 2013
Maks3w added a commit that referenced this pull request Oct 21, 2013
@Maks3w Maks3w merged commit a893702 into zendframework:develop Oct 21, 2013

class UpdateIgnore extends Update
{
const SPECIFICATION_UPDATE = 'updateIgnore';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this const in child class is excess.
try remove it - all tests is OK.
you override specification - to my mind it is enough.
so - in this PR needs only tests changes.
maybe changes in the test not need too - if you override specification - what do you expect to see?

@turrsis
Copy link
Contributor

turrsis commented Oct 22, 2013

#5323 - revert static::SPECIFICATION_* and tests is ok.

@corentin-larose corentin-larose deleted the self-to-static-for-extendability branch March 14, 2014 12:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants