pgsql and exception
- From: Une Bévue <unbewusstsein@xxxxxxxxxxx>
- Date: Mon, 14 May 2012 08:39:13 +0200
I have an INSERT generating an exception :
ERROR: value too long for type character varying(30)
this error comes from try out usinf command line.
I'd like to print-out this error when using this database from php.
Then, i did :
$ret=$db->query($sql);
try {
while($row=$ret->fetch()){ // line 492
$rowid=$row['rowid'];
}
// do something
} catch (Exception $e) {
echo $e->getMessage()."<br />\n";
}
or using :
} catch (PDOException $e) {
echo $e->getMessage()."<br />\n";
}
From php i get :
Fatal error: Call to a member function fetch() on a non-object in /Users/yt/Sites/landp_public/landp.php on line 492
line 492 being "while($row=$ret->fetch()){"
obviously the best way is to avoid having a varchar column with a length lower than 30.
could i get the error from $ret ?
.
- Follow-Ups:
- Re: pgsql and exception
- From: "Álvaro G. Vicario"
- Re: pgsql and exception
- From: M. Strobel
- Re: pgsql and exception
- From: Une Bévue
- Re: pgsql and exception
- Prev by Date: Re: Windows binaries 64bit for PHP
- Next by Date: Re: pgsql and exception
- Previous by thread: Re: First question and introducing myself
- Next by thread: Re: pgsql and exception
- Index(es):
Relevant Pages
|