I had the same error with my first PDO attempt, however I was using Zend Framework so the execution was a little different, but I can give you some suggestions, first I will give you a note from the manual, then you can see the attributes I added to end up getting it to work right.
Try this:
As per the PHP Manual,
When initializing the PHP statement Try:
$MyPdo = new PDO("mysql:dbname=dbname;host=some.ip", "user", "pass", array(
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
));
I also user some other PDO directives, PDO::ATTR_PERSISTENT and PDO::ATTR_LIMIT_PREPARES
$MyPdo = new PDO("mysql:dbname=dbname;host=some.ip", "user", "pass", array(
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true,
PDO::ATTR_PERSISTENT => true,
PDO::ATTR_LIMIT_PREPARES => true
));
If the above doesn't work out for you, you can try adding the other parameters using the same method as you have described.
// Your Method, if above doesnt work
$MyPdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY,true);
$MyPdo->setAttribute(PDO::ATTR_PERSISTENT,true);
$MyPdo->setAttribute(PDO::ATTR_LIMIT_PREPARES,true);
Best of luck