Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

Claudio Vendrame
Claudio Vendrame
4,964 Points

As a beginner MYSQL, MYSQLi, PDO. What the best choice .

As a beginner I can see a lot of difference between MYSQL, MYSQLi and PDO. Before I get deeper in PHP I would like to know the best place to start. I understand that all of them offers different usability but I am not in a high level yet. And probably will not be for a while, hahaha.

Any advice?

Thank you!

2 Answers

Luc de Brouwer
seal-mask
.a{fill-rule:evenodd;}techdegree
Luc de Brouwer
Full Stack JavaScript Techdegree Student 17,939 Points

Hi Claudio,

The difference between MySQL and MySQLI is the version. In the future MySQL functions will be deprecated which means that it will no longer be supported in nearby versions. SQL will still stay SQL, only the functions get an extra i in its code.

My personal experience is to use Procedural PHP, which is much easier to get into and much easier to understand and get the hand of it than Objected Oriented & PDO, but give it a shot and see which suits you best.

for example if you try to make a query with Procedural all you have to do is give 2 variables along with the function which takes them as parameter. Where in parameter 1 should be the connection variable, either included in the file or written in the file itself, and the variable which contains the query

f.e: $query = "SELECT * FROM phpdatabase"; $result = mysqli_query($conn, $query);

Claudio Vendrame
Claudio Vendrame
4,964 Points

That is nice information. I checked the Mysql and Mysqli, I couldn't see a huge difference in the way It is coded but in case of the PDO, It was a little out of my league. I guess Mysql is out of the list. Just have to decide between Mysqli and PDO. Probably will start with Msqli.

Thank you very much again.

Antonio De Rose
Antonio De Rose
20,884 Points

mysql - no, as it is deprecating. mysqli - is what, what I would recommend, as you have mentioned, you are a newbie PDO - is what, you have to ultimately aim for.

Claudio Vendrame
Claudio Vendrame
4,964 Points

Hi! I have learn a little of Mysql in the past so it would be easier to jump to Mysqli. As far as I could see PDO looked a bit scary to me, hahaha. To know that I can learn first Mysqli and then aim for PDO makes me feel more confident.

Thank you for sharing your opinion.