Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP

Lucas Santos
Lucas Santos
19,315 Points

Can I still learn from mySQL course even though he writes his SQL differently?

In the PHP with mySQL course Randy writes his mySQL code in a PDO format. I write mySQL with MySQLi Object-Oriented format. Is it still possible to learn form this course even tho he writes his mySQL different than mine. Also I use the MySQLi Object-Oriented format because I read that currently it's the best way to write your mySQL code.

2 Answers

Peter Smith
Peter Smith
12,347 Points

I'm a novice at MySQL and PHP but the thing that matters most to me is preventing MySQL injection exploits. Based on that, influenced by my reading here I think PDO is better than MySQLi. I'm specifically referring the line in the linked document, which states in its Language specific recommendations section... "PHP – use PDO with strongly typed parameterized queries (using bindParam())"

Lucas Santos
Lucas Santos
19,315 Points

I read some other articles and they do recommend PDO. So I think i'll have to convert over to PDO. Thanks a lot Peter

I've read quite a few convincing arguments between the two, but personally I always go for PDO because it's better - and at no extra cost.

This article gives quite a nice, non-bias comparison between the two. PDO just has a few more things going for it - probably features you wouldn't really use that often - but because the differences in overhead is minimal, I would suggest converting to PDO.

Regardless - if you can connect to a database using a safe and protected method, that's all good!

Lucas Santos
Lucas Santos
19,315 Points

I see good article I guess i'll have to learn the PDO format. Thanks for the advice