It is said because most attempts to create a PDO wrapper are indeed helpless and make things worse than with raw PDO.
Also premises, one is writing their wrapper based upon, are mostly wrong.
Let's take yours:
You handle all your data in one class, not spread across your website files.
Quite vague statement, with no particular meaning. Surely you handle your data all across the application but using not raw PDO but using your own class.
You can easilly change your class with another databaseclass.
But a delusion. You can't actually stick to your two helper methods - sometimes you need to use raw PDO instance.
You don't have to repeat your code, just call the code in the databaseclass
this one is quite true. But not that useful as with any other API.
Optionally you can extend the class with for example logging, statistic tests
This is a proper one - no objections.
This is a lot more efficiënt than everytime open a connection, perform 3 lines of code and close it.
this is a false one. Nobody asks you everytime open a connection, perform 3 lines of code and close it. Even with raw PDO connection is opened only once.
However, your implementation is quite good. It doesn't add too much to raw PSO (actually, it shorten repetitions by just one line only) but still being sensible. So - I'd call this approach rather successful.
Some suggestions:
- there is indeed no point in storing database credentials as class properties. They needed in constructor only and nowhere else
- Why not to create a connection right in the constructor, without the need for extra method?
- public function getOne() would be indispensable addition to your set.
- You need to make $connection public - at least until you make all the methods available from both PDO and PDOstatement