Hacker News new | ask | show | jobs
by generalpf 4595 days ago
Shouldn't everyone be on PDO by now? If you're still on mysql[i]_ you must be used to having problems.
3 comments

Should be, absolutely.

Are, nope.

PHP's long-lived popularity means there's a huge amount of ancient PHP articles and tutorials still out there on the web that use the old library. Because these articles are both old and widely linked-to, they tend to come up when newbies search for PHP help. So they learn how to do things the wrong/deprecated way.

Resources like PHP the Right Way (http://www.phptherightway.com/) help counter this, but it'll continue to be a problem as long as using the old library doesn't cause any obvious problems like immediate crashes, screaming in-your-face error messages, etc.

I maintain an early 2000's php website that is pretty functional and has a lot of features, but uses the classic spaghetti code. I can't exactly just switch to PDO without considerable time investment, and otherwise things are working just fine. I don't think this is an uncommon scenario.
I converted an OSS application that I wrote back in '03 to PDO in just a few hours. It actually helped me find security holes because of strong typing in bound parameters. Have a go!
Probably. I'm a pretty poor developer. I'm a sysadmin who sometimes writes PHP apps for work. So, I'll look into PDO. :D
lmm: (For some reason your post doesn't have a reply link) These are usually webapps for department-specific needs, and I generally find PHP to be easier. I have a few python things that I use on the backend, as well as a plethora of bash scripts. But, I admit to knowing PHP more than Python. (I'm in a smallish company, so I end up wearing a lot of hats)

generalpf: I will do so! Do you have any go-to references that you prefer? Or shall I just dig through the PHP docs?

It's really quite simple, read this and get to work! It also explains the 'why'.

http://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers

> For some reason your post doesn't have a reply link

I think that for a comment at some level of nesting N, the ability to replay is delayed by Y seconds. IIRC this is to prevent stupid back-and-forth arguments.

Definitely recommended! It will also help you when you swap out MySQL for something else later on... little to no rework!
If you've got the time, try writing one in python and see what you think.