Closed Philippe-M closed 3 years ago
You can use $database->error() for that -> https://medoo.in/api/error
I use it already
public function createTable($tableName) {
switch ($tableName) {
case 'stock_tmp':
$this->database->query("
CREATE TABLE `stock_tmp` (
`itmref` varchar(20) NOT NULL,
`status` varchar(1) NOT NULL,
`qtystu` decimal(10,5) NOT NULL,
`cumallqty` decimal(10,5) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;"
);
var_dump($this->database->error());
break;
}
But it does not work.
i see. i never used Medoo to create temporary database so i dont know (only for the first install of the script). it may be a bug : @catfan ?
Good luck !
I am trying to use error handling for any queries I make through Medoo. This example is another among many others in my scripts
If you create no problem at first time. Why do not use CREATE TABLE IF NOT EXISTS
?
This query is just an example. I use Medoo for all my program which makes insert, get, update ... And for the moment if a few things go wrong during the query I have a big error php and not the error handling as provided in Medoo
Hello, i've this code
I call createTable a first time, I have no (normal) error. I call it a second time I have an error but it is not medoo that returns it to me but php.
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'stock_tmp' already exists' in /var/www/html/plugins/portail/include/Medoo.php:306 Stack trace: #0 /var/www/html/plugins/portail/include/Medoo.php(306): PDOStatement->execute() #1 /var/www/html/plugins/portail/include/Medoo.php(276): Medoo\Medoo->exec('\n CREA...', Array) #2 /var/www/html/plugins/portail/api.php(43): Medoo\Medoo->query('\n CREA...') #3 /var/www/html/plugins/portail/test.php(15): api->createTable('stock_tmp') #4 {main} thrown in /var/www/html/plugins/portail/include/Medoo.php on line 306
php stops code execution and error is not intercepted by medoo.
How-to use medoo for intercepte error ?