Re: DB_DataObject: database error code
| From: | Alan Knowles | Date: | Tue, 19 Jul 2005 08:18:17 +0000 |
| Subject: | Re: DB_DataObject: database error code | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20054@lists.php.net to get a copy of this message | ||
insert() should return false on error, so
if ($do->insert() === false) {
$code = $do->_lastError->getCode();
....
Regards
Alan
On Tue, 2005-07-19 at 09:19 +0300, Laszlo Hermann wrote:
> I would like to process the error IN THE SCRIPT. i.e., when the error
> code is 1062 the script should display a message like "hey dude,
> duplicate entry!" Is there a way to do this?
>
> On 7/19/05, Alan Knowles <alan@akbkhome.com> wrote:
> > On Mon, 2005-07-18 at 13:47 +0300, Laszlo Hermann wrote:
> > > Dear ...,
> > >
> > > Is there a way to see what error code did the sql server return? (for
> > > example msyql returns 1062 for duplicate entries)
> > >
> > > I'm talking about DB_DataObject.
> > turn debugging on... or print_r() the dataobject, it's one of the
> > variables.. (there may also be a method for retrieving it, but I cant
> > remember of the top of my head)
> >
> > Regards
> > Alan
> > >
> > > Thanks,
> > >
> > > Laszlo.
> >
> >