DB Error: mismatch when using PEAR::DB

If this:

$sql="SELECT col FROM table WHERE id=5";
$dbh->query($sql,DB_FETCHMODE_ASSOC);

yields a very informative “DB Error: mismatch”, revise the way you are submitting the query… Removing DB_FETCHMODE_ASSOC gets rid of the error. Why? DB_FETCHMODE_* is used only when you are using GetAll, GetOne, FetchRow, etc.

If you need to use it, do this:
$dbh->setFetchMode(DB_FETCHMODE_ASSOC);
$result = $dbh->query($sql);

Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages.
  • blinkbits
  • BlinkList
  • del.icio.us
  • digg
  • Fark
  • Furl
  • Reddit
  • Spurl
  • YahooMyWeb

Leave a comment

Please be polite and on topic. Your e-mail will never be published.