catfan / Medoo

The lightweight PHP database framework to accelerate the development.
https://medoo.in
MIT License
4.84k stars 1.15k forks source link

use $database->error() cannot return the error number and error message. #568

Closed mysizeofcn closed 7 years ago

mysizeofcn commented 7 years ago

To use $database->error() cannot return the error number and error message, the var_dump() tell me the error number is 00000 , please tell me how to deal with it ? Thanks for much.

mysizeofcn commented 7 years ago

Oh forget version , so I used the Medoo Version is 1.4.1

catfan commented 7 years ago

If return 00000, that mean is successful and nothing wrong.

http://php.net/manual/en/pdo.errorcode.php

The message number is depends on PDO driver. Having a number doesn't mean you are wrong.

wongwangki commented 7 years ago

I also got this problem, i query a wrong query

ie: $db->select(INVALID_TABLE,[]);

then $db->error();

it always return 00000, but there is an error when i var_dump in the core : $query->errorInfo();

wongwangki commented 7 years ago

select() function:

$query = $this->exec($this->selectContext($table, $map, $join, $columns, $where), $map); return $query->errorInfo();

add this line, it shows the correct error info; but doesn't show when call $db->error();

mysizeofcn commented 7 years ago

THANKS 4 MUCH

catfan commented 7 years ago

Well, I checked this issue again. It's a bug return incorrect error info, and I fixed it.

blessedjasonmwanza commented 4 years ago

@mysizeofcn Well, i think you can get the error message using $database->error()[2] The 3rd array index holds a readable SQL error Massage that is returned. It works for me, hopefully id does for you as well.

NB always check the first index value of the error e.g ($db->error()[0]), if it equates to 00000 i.e( five zeros), the your last operation run successfully.