Medoo icon indicating copy to clipboard operation
Medoo copied to clipboard

Medoo and error managment

Open bcmfr opened this issue 13 years ago • 2 comments

Hi

first of all, thank you fort the good work! I really like using Medoo, this is so easy!

However, i have to say that i don t really understand how it work when there is an error, for exemple, if i do a select request for a table that doesen t exist, how can i get the error specificly and not the array with var_dump($Db->error());

I'm sorry but i really don t understand?

bcmfr avatar Jun 30 '13 16:06 bcmfr

I mean, if i don 't want the array to be display on the screen of the visitor, is there a possibility to create a variable when there is an error, and then look with isset() if this variable exists? So i would be abble to show an specific error message to my visitor?

bcmfr avatar Jun 30 '13 16:06 bcmfr

medoo gives back array from errorInfo from pdo/php, so have a look at http://php.net/manual/de/pdo.errorinfo.php

I think you're looking for the error code (e.g. 42S02) which is index [0] in the array. So instead of var_dump you can try echo $database->error()[0];

and handle based on error codes.

fgusinde avatar Sep 04 '13 08:09 fgusinde