I have a very simple test script:
Same issue but different cause here
My solution was just a simple apt-get install php-mysql away
Be sure to check for pdo_mysql in your phpinfo()
Found it on this post : PDOException “could not find driver”
I wonder why CLI worked in such conditions O_o Maybe something installed incorrectly, or got overriden ? Well, now, it works fine !