MySQL connectivity, what should I be using?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
iCoolUserName
Forum Newbie
Posts: 4
Joined: Thu Mar 06, 2014 6:07 pm

MySQL connectivity, what should I be using?

Post by iCoolUserName »

Hey there,

So I'm in the middle of designing my first "website" in the sense that I'm a noob with PHP/MySQL, I've never used them before and as such have taken it upon myself to learn them, thankfully some of my previous programming skills are semi-transferable as I feel more or less "up to speed" with PHP. Earlier I had a slight issue where I couldn't format the output from a mysql query correctly and so hit google to find a solution, I didn't (I figured it out anyway), I found more questions than I did answers :banghead: .

As such my questions are as followed:
What is the current method of connecting/performing computations on a MySQL DB? I've been using MySQL_*, but it appears MySQLi_* would be more efficient.

The php.net website further indicates that mysql_* is deprecated and the way to go is some mystical mumbo jumbo called PDO (PHP Data Objects), is this; A) Correct & B) Future proof?

Besides this: http://uk1.php.net/manual/en/book.pdo.php
Can you recommend an good resources/tutorials geared at/containing PDO?

Thanks.

PS:The mystical bit was a joke, it was funny, ha-ha
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: MySQL connectivity, what should I be using?

Post by Celauran »

MySQLi does indeed replace the deprecated MySQL driver but I find it to be cumbersome to use. PDO is definitely the way to do and is what many ORMs use under the hood. The book you linked is as good a place as any to start. The basic principles are the same, so migrating from mysql_ to PDO should be reasonably painless.
iCoolUserName
Forum Newbie
Posts: 4
Joined: Thu Mar 06, 2014 6:07 pm

Re: MySQL connectivity, what should I be using?

Post by iCoolUserName »

Thank you,
the speed at which web technologies move is irksome. I've been using a book that's not even 2 years old and it's out dated.
Post Reply