Error handling with PDO

I have Laragon installed now, but I see no option for importing a database. How do I use it to import a database? I’ve clicked all the options and there is nothing obvious.

You need to use your MySQL control panel. Log into your hosting control panel and look for the database
area. Then in your list of databases, you will see something like phpMyAdmin. That is often next to the list
of names for the databases you have created. In there, you can adjust your database tables, add new ones,
delete others and import data. Imported data can be in the form of a “.sql” file which will set up everything.
The bumpstart package above should have instructions about it all.

Read everything on phpdelusions.net. Maybe spend half an hour every saturday morning reading it. It’s full of good infomation you need to know for when you inevitable encounter PDO in the wild.

But in my opinion, 97% of the time you can get more done and enjoy life by using any model/orm/active-record/query-builder library out there. If you’re doing something simple, use a simple one like Idiorm / Paris - http://j4mie.github.io/idiormandparis/ https://idiorm.readthedocs.io/en/latest/

But… in properly functioning software there shouldn’t be any errors to display… no? If there are errors it would be with form validation prior to touching the database and you would control what those errors say and when they’re shown.

What kind of errors from the database are you anticipating getting frequently and why?

If manually using prepared statements (or a library that automatically uses them internally) you won’t ever have to worry about an sql syntax error.

If all your record primary key id’s are auto-increment generated and your web forms don’t allow editing the primary key you shouldn’t have to worry about any attempts at creating a duplicate record.

If your form validation handles any other incorrect usage of the form fields then I can’t really think of a reason why you would want to show PDO related errors to the end user because I can’t think of any errors you would really have. Am I wrong?

Use a framework or at least a db library that handles the prepared statement work automatically or the new mysql X devapi which is pure code instead of strings of sql syntax.

Sponsor our Newsletter | Privacy Policy | Terms of Service