Welcome Guest, Not a member yet? Register   Sign In
question about database query error message
#1

[eluser]quals_jack[/eluser]
HI, all

By using database class, how do I get the error message from database when a query gets an error? Thank you in advance!


Jack
#2

[eluser]Randy Casburn[/eluser]
forget the CI DB Class...this is straight up PHP... mysql_error() will retrieve the most previous query error from the default mysql connection. If you have more the one connection open you can pass it a connection id.

Randy
#3

[eluser]Colin Williams[/eluser]
Hrm.. Don't MySQL errors already get output via the show_error() function when using the DB lib?
#4

[eluser]quals_jack[/eluser]
You mean by using $this->DB->show_error() in CI DB class? I'm using postgreSQL, I think it's tha same?

Jack
#5

[eluser]Randy Casburn[/eluser]
Maybe...and that's the key difficulty. This would be dependent on your PHP error_reporting() configuration setting at the top of your index.php file.

There is no question about the mysql_error() function.

Randy
#6

[eluser]Randy Casburn[/eluser]
Postgres uses SQLSTATE codes. So your two choices are CI's show_error() as Colin has correctly described (make sure your error_reporting is set properly) or since you are using Postgres, you must retrieve the SQLSTATE from the DB in order to get the error status.

Randy




Theme © iAndrew 2016 - Forum software by © MyBB