Re: cvs: php4 /pear DB.php
| From: | Stig S. Bakken | Date: | Wed, 18 Jul 2001 00:27:58 +0000 |
| Subject: | Re: cvs: php4 /pear DB.php | ||
| References: | 1 | Groups: | php.pear.cvs |
| Request: | Send a blank email to pear-cvs+get-290@lists.php.net to get a copy of this message | ||
What problem? Was I relying on a feature newer than I thought?
- Stig
Chuck Hagenbuch wrote:
>
> chagenbu Tue Jul 17 12:01:16 2001 EDT
>
> Modified files:
> /php4/pear DB.php
> Log:
> fix problem with static usage...
>
>
> Index: php4/pear/DB.php
> diff -u php4/pear/DB.php:1.70 php4/pear/DB.php:1.71
> --- php4/pear/DB.php:1.70 Sun Jul 15 18:54:08 2001
> +++ php4/pear/DB.php Tue Jul 17 12:01:16 2001
> @@ -17,7 +17,7 @@
> // | Tomas V.V.Cox <cox@idecnet.com> |
> // +----------------------------------------------------------------------+
> //
> -// $Id: DB.php,v 1.70 2001/07/15 22:54:08 ssb Exp $
> +// $Id: DB.php,v 1.71 2001/07/17 16:01:16 chagenbu Exp $
> //
> // Database independent query interface.
> //
> @@ -341,40 +341,43 @@
> */
> function errorMessage($value)
> {
> - static $errorMessages = array(
> - DB_ERROR => 'unknown error',
> - DB_ERROR_ALREADY_EXISTS => 'already exists',
> - DB_ERROR_CANNOT_CREATE => 'can not create',
> - DB_ERROR_CANNOT_DELETE => 'can not delete',
> - DB_ERROR_CANNOT_DROP => 'can not drop',
> - DB_ERROR_CONSTRAINT => 'constraint violation',
> - DB_ERROR_DIVZERO => 'division by zero',
> - DB_ERROR_INVALID => 'invalid',
> - DB_ERROR_INVALID_DATE => 'invalid date or time',
> - DB_ERROR_INVALID_NUMBER => 'invalid number',
> - DB_ERROR_MISMATCH => 'mismatch',
> - DB_ERROR_NODBSELECTED => 'no database selected',
> - DB_ERROR_NOSUCHFIELD => 'no such field',
> - DB_ERROR_NOSUCHTABLE => 'no such table',
> - DB_ERROR_NOT_CAPABLE => 'DB backend not capable',
> - DB_ERROR_NOT_FOUND => 'not found',
> - DB_ERROR_NOT_LOCKED => 'not locked',
> - DB_ERROR_SYNTAX => 'syntax error',
> - DB_ERROR_UNSUPPORTED => 'not supported',
> - DB_ERROR_VALUE_COUNT_ON_ROW => 'value count on row',
> - DB_ERROR_INVALID_DSN => 'invalid DSN',
> - DB_ERROR_CONNECT_FAILED => 'connect failed',
> - DB_OK => 'no error',
> - DB_WARNING => 'unknown warning',
> - DB_WARNING_READ_ONLY => 'read only',
> - DB_ERROR_NEED_MORE_DATA => 'insufficient data supplied'
> - );
> + static $errorMessages;
> + if (!isset($errorMessages)) {
> + $errorMessages = array(
> + DB_ERROR => 'unknown error',
> + DB_ERROR_ALREADY_EXISTS => 'already exists',
> + DB_ERROR_CANNOT_CREATE => 'can not create',
> + DB_ERROR_CANNOT_DELETE => 'can not delete',
> + DB_ERROR_CANNOT_DROP => 'can not drop',
> + DB_ERROR_CONSTRAINT => 'constraint violation',
> + DB_ERROR_DIVZERO => 'division by zero',
> + DB_ERROR_INVALID => 'invalid',
> + DB_ERROR_INVALID_DATE => 'invalid date or time',
> + DB_ERROR_INVALID_NUMBER => 'invalid number',
> + DB_ERROR_MISMATCH => 'mismatch',
> + DB_ERROR_NODBSELECTED => 'no database selected',
> + DB_ERROR_NOSUCHFIELD => 'no such field',
> + DB_ERROR_NOSUCHTABLE => 'no such table',
> + DB_ERROR_NOT_CAPABLE => 'DB backend not capable',
> + DB_ERROR_NOT_FOUND => 'not found',
> + DB_ERROR_NOT_LOCKED => 'not locked',
> + DB_ERROR_SYNTAX => 'syntax error',
> + DB_ERROR_UNSUPPORTED => 'not supported',
> + DB_ERROR_VALUE_COUNT_ON_ROW => 'value count on row',
> + DB_ERROR_INVALID_DSN => 'invalid DSN',
> + DB_ERROR_CONNECT_FAILED => 'connect failed',
> + DB_OK => 'no error',
> + DB_WARNING => 'unknown warning',
> + DB_WARNING_READ_ONLY => 'read only',
> + DB_ERROR_NEED_MORE_DATA => 'insufficient data supplied'
> + );
> + }
>
> if (DB::isError($value)) {
> $value = $value->getCode();
> }
>
> - return $errorMessages[$value];
> + return isset($errorMessages[$value]) ? $errorMessages[$value] :
> $errorMessages[DB_ERROR];
> }
>
> /**
>
> --
> PEAR CVS Mailing List (http://pear.php.net/)
> To unsubscribe, e-mail: pear-cvs-unsubscribe@lists.php.net
> For additional commands, e-mail: pear-cvs-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net