PDO is just a fail


I’ve always wanted to try this “awesome” PDO thing, everyone is talking about it, it was like a miracle came from nothing, They are saying that mysql extension is getting deprecated, Bullshit !

Yes, the Old fashioned MySQL extension is planned to be deprecated but in a long term, so why bother with this new PDO thing ? you should, because it is cross-database, which means the same code works perfectly with all supported databases (well maybe few changes but it is ofcourse way better than rewriting every code in the project).

That made me try it, only that, and I got disappointed and I’m feeling bad for the wasted time :(

The main issue I’ve had is that you can do ONE operation on each query, which means if you want to organize an array from your SELECT query after checking if there are rows or not is not possible, you have to re-query again, which is plain bad.

another thing is lack of SQL error reporting, if the query fails, it returns FALSE, and doesn’t return an error or something, which is again Bad, you have to look for the error yourself.

I’ve had other problems like server crashing twice, “too many connections to the server” “MySQL gone away” and that is enough !

I’ll not go back to PDO again, NEVER, Until they deprecate the OLD fashioned MySQL extension, I’ll move to MySQLi or just use another database without bothering with too many retarded details

Best Regards


Ever thought about FIXING the errors than Overriding them ?

The first version of this title was : “Ever thought about FIXING the DAMN errors than Overriding them ?”, and I mentioned it here to make sure you feel that it is an annoying issue and cannot be handled easely.

Before I start, What is error overriding ? 

Basically it is using ‘@’ before functions to disallow the PHP Parser from printing/log-ing errors.

While it can be handy to use; like in some situations where the dl() function prints some warnings if used when a library doesn’t exist in the server. Some developers just over use it because it just *saves* time for them, since warnings will most likely won’t stop the script from working, but it really hurts in many cases.

Really... Don't, copyrights goes to me on creating this meme ;)

I’ve witnessed many cases where some functions are misused, then the coder just overrides it :

//mysql connection goes here
//update the counter, someone new visited !
$query = mysql_query('UPDATE `counter` SET `visits` =  'visits'+1;');
//show number of visits
$query = mysql_query('SELECT * FROM `counter`;');
$rows = mysql_fetch_array($query);
//print the visists !
print "We have $rows['visists'] visit(s) so far !";

Along with the old fashioned way of doing things, and performance issues (shouldn’t matter in this file, but it will when you have big script running on a big site), this man did exactly what i hate T_T.

the out put of the code above will be something similar to this : 

"We have 11 visit(s) so far !"

yea sounds cool, but what if we remove the ‘@’ before the mysql_free_result() function ??

"Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in retardedfile.php on line 6

We have 12 visit(s) so far !”

This means that the parser found that the object returned from the UPDATE query isn’t a valid MySQL result, it returned a Boolean (obviously) in our case it will be TRUE since it really updated the counter, BUT; it did free the memory from the second query, SELECT query, which it returned a valid MySQL result and not a Boolean.


If you have read everything this far, You must certainly understand that error overriding isn’t the best option to hide errors and move forward, such errors *WILL* break your code, and break other coder’s mind if they are working along with your code, don’t make them suffer from your ignorance, be safe (not all the coders are cold mannered ;) ).

Tags: PHP