Re: What is wrong with this code?
| From: | Gary . | Date: | Wed, 28 Apr 2010 07:18:45 +0000 |
| Subject: | Re: What is wrong with this code? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304698@lists.php.net to get a copy of this message | ||
On 4/28/10, Jochem Maas wrote:
> Op 4/28/10 7:39 AM, Gary . schreef:
>> class Pg_Error
>> {
const INTEGRITY_CONST_UNIQUE = '23505';
>> 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;
>> }
>> ...
>> }
...
> I'd be looking at making sure the constant 'INTEGRITY_CONST_UNIQUE' is
> actually
> defined before you load the class ...
I accidentally deleted it in the example I posted. Sorry. The actual
code includes the above const. But you put me on the right track, the
array entry wasn't using the const value as a key...