Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
There are many options for working with databases in PHP, such as MySQL, PostgreSQL and SQLite. If you work with PDO then you can connect to any of them with the same code, so learn how to do it once and be able to work with other systems much more easily in the future.
-
0:00
[NOISE] When you build an aggregation with PHP 99% of
-
0:04
the time you'll be interacting with some sort of data store.
-
0:09
And this is very often an SQL database.
-
0:12
SQL stands for structured query language.
-
0:15
If you're unfamiliar with SQL databases, you should check out the course,
-
0:19
database foundations.
-
0:22
SQL databases allow you to save users, blog posts,
-
0:25
payment information, and whatever else your website will need to remember, and
-
0:28
provides you with an interface to fetch that data back whenever you need it.
-
0:31
There are many options for
-
0:34
working with databases in PHP, such as MySQL, PostgreSQL, and SQLite.
-
0:39
MySQL is incredibly popular with the PHP community.
-
0:41
But if you end up using that, you have to be careful.
-
0:45
There are three extensions that can be used to connect to
-
0:48
MySQL databases and PHP.
-
0:50
MySQL, MySQLI, and PDO.
-
0:53
The MySQL extension is currently deprecated, and
-
0:56
will be removed from the upcoming version of PHP.
-
0:59
You shouldn't use this for anything anymore.
-
1:01
MySQLI and PDO are the only remaining safe options.
-
1:04
If you are not using MySQL and decide to go with another popular system,
-
1:07
like Postgres or SQL Lite, then there are extensions for
-
1:10
that too, such as PGSQL, SQLite, and also PDO.
-
1:15
If you are unsure which to use, a sensible option is to always work with PDO.
-
1:20
PDO allows you to learn one PHP API for interacting with many supported databases.
-
1:25
This allows you to use the same API to interact with MySQL, Postgres, and SQLite,
-
1:30
or many others without having to relearn a brand new set of functions and classes.
You need to sign up for Treehouse in order to download course files.
Sign up