Pdo Installation for Mysql and other database

Pdo ( Portable Data Object ) needs to be installed if it is not done before. For windows platform goto control panel > Add remove program ( or Programs and features ) > Select your PHP installation and click Change. If you are installing PHP fresh then in the setup wizard you can select PDO from Extensions link.
PHP setup for PDO
Based on the database type you can enable or disable PDO drivers. Note that once you have done this process then automatically php.ini file gets edited and you may have to reboot your system. Note that PDO drivers are in your extension directory and in php.ini file this it to be enabled.
extension for PDO drivers

extension=php_pdo.dll

But in PHP 5.3 and above these dll are not required.
After installing pdo you can check your phpinfo function and ensure that PDO support is enabled.
PHP info page for PDO drivers

Checking PDO Installation

You can get all the PDO drivers installed in your system by using getAvailableDrivers() function. We will get an array with a list of drivers installed. Here is the code.

print_r(PDO::getAvailableDrivers());

We can check by using in_array function about any particular driver installed or not.

if(in_array("mysql",PDO::getAvailableDrivers())){
echo " You have PDO for MySQL driver installed ";
}else{
echo "PDO driver for MySQL is not installed in your system";
}

Download Zip file to test your PHP PDO script

Be the first to post comment on this article :


Google+

Post Comment This is for short comments only. Use the forum for more discussions.




HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2015 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer