ZF-8012: The example code of Zend_Validate_Db_NoRecordExists does not work

Description

Hi. The example code of '59.2.8.2. Excluding records' does not work. See http://framework.zend.com/manual/en/…

This code does not work.


$validator = new Zend_Validate_Db_NoRecordExists(
    array(
        'table' => 'users',
        'field' => 'username',
        'exclude' => array(
            'field' => 'id',
            'value' => $user_id
        )
    )
);

This one works fine.


$validator = new Zend_Validate_Db_NoRecordExists(
    'users',
    'username',
    array(
        'field' => 'id',
        'value' => $user_id
    )
);

Regards.

Comments

Are you working from trunk? Thomas recently made a change to the validator which means the DB validators now work with an options array, instead of a bunch of parameters. The notation is correct for trunk, which the docs are built from. This is a BC break, and so should not be changed in a release until 1.10

Thank you for comment. I'm not working on trunk(just a released version) and I understand docs for trunk.

Regards.

Ryan: No, this is no BC break. With 1.10 both notations are accepted. So you can use Zend_Config as with 1.10, which is now not possible. It's a new feature, no BC break as the old notation is still accepted.

Related to docu. Normally the manual is build from trunk but only for the minor release. It seems as the build process is broken and the manual is build from trunk even for mini releases and even as we commit related docu changes to branch.

This is a problem of the build process, and not the manual. The dev-team has already been pointed to the problem, but it needs some time to fix the process.

It would be interesting if the packaged manual is identical with the manual from the homepage.

Closing as "non-issue" for the above noted reasons. Needs a fix for the build process by the dev-team.

The following code causes an error at the first line, because the constructor expects an array with table and field name. I think this is no expectable code behavior. You should make the class throw an error when validating, not in the constructor.


$validator = new Zend_Validate_Db_NoRecordExists();
$validator->setTable('user');
$validator->setField('username');