Jump to content

how to get sql error code returned by the server


Recommended Posts

Is there a way to get the sqlcode error code returned by the server after a sql is executed agains it.
In my case I need to know if a certain column was already added to a table, for example this code:

// Add nacionality field to customer table
   $query = 'ALTER TABLE `' ._DB_PREFIX_.'customer`
             ADD `nationality` int(10) unsigned NULL default 0';
   $result=Db::getInstance()->Execute ($query);

in this case the Db class returns false if the sql fails, but I cannot guarantee that it failed because the column already exists, it could be false maybe because the user has not rights over that table.
This would be useful to display the correct error message to the user who is trying to install this module for instance.

thanks for your help



Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...