Re: What is wrong with this code?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28 April 2010 08:39, Gary . <php-general@xxxxxxxxxxxxxxx> wrote:
> class Pg_Error
> {
>    private static $errors =
>        array(INTEGRITY_CONST_UNIQUE => 'uniqueness constraint violated');
> ...
>    public static function getMessage($ec)
>    {
>        $text = '';
>        if (array_key_exists($ec, Pg_Error::$errors))
>        {
>            $text = Pg_Error::$errors[$ec];
>        }
>
>        return $text;
>    }
> ...
> }
>
> ?
>
> Calling it, the array_key_exists call always returns false:
> $this->assertEquals('uniqueness constraint violated',
> Pg_Error::getMessage(Pg_Error::INTEGRITY_CONST_UNIQUE));
> and I can't see what I've done wrong :(
>

In your code snippet, you do not declare
Pg_Error::INTEGRITY_CONST_UNIQUE - and equally to the point, in the
class you only use INTEGRITY_CONST_UNIQUE in the array, not
Pg_Error::INTEGRITY_CONST_UNIQUE

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
Flickr: http://www.flickr.com/photos/fake51
BeWelcome: Fake51
Couchsurfing: Fake51
</hype>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux