PDO is the standard, it's what most developers will expect to use. mysqli was essentially a bespoke solution to a particular problem, but it has all the problems of the other DBMS-specific libraries. PDO is where all the hard work and clever thinking will go.
People keep on mentioning that I should be using PDO in my PHP when dealing with MySQL, I have never heard of this before. What is PDO? How is it used and what are the pros and cons? Thanks,
Inside my sqlQuery - class, which extends my connect_pdo - class, I have a public function called getAreaName which handles the request to my database. Pretty neat I think. Works like a charm So that's basically how I'm doing it. Also, whenever I need to fetch something from my DB from not within a class, I just do something similar to this:
47 Should I use php PDO or normal mysql_connect to execute database queries in PHP? Which one is faster? One of the big benefits of PDO is that the interface is consistent across multiple databases. There are some cool functions for prepared statements too, which take some of the hassle out of escaping all your query strings.
While this answer is probably correct and useful, it is preferred if you include some explanation along with it to explain how it helps to solve the problem. This becomes especially useful in the future, if there is a change (possibly unrelated) that causes it to stop working and users need to understand how it once worked.
Add to that, some of the PDO drivers emulate prepared statements, and there's room for them to do so incorrectly (for instance, by half-assedly parsing the SQL).
extension=pdo.so extension=pdo_sqlite.so extension=pdo_mysql.so extension=sqlite.so If they are not present, simply add the lines above to the bottom of the php.ini file and save it.
The answer is in the documentation for bindParam: Unlike PDOStatement::bindValue (), the variable is bound as a reference and will only be evaluated at the time that PDOStatement::execute () is called. And execute call PDOStatement::bindParam () to bind PHP variables to the parameter markers: bound variables pass their value as input and receive the output value, if any, of their associated ...
First, check if your php.ini has the extension enabled "php_pdo_mysql" and "php_mysqli" and the path of "extension_dir" is correct. If you need one of above configuration, then, you must restart the php-fpm to apply the changes.