My current Website Control Panel is PLESK Parallels, and i’m trying to use PDO MSSQL on my website.
I’ve searched the internet and i’m aware that the PDO dll needs to be in my php.ini file and such, but I keep reading different ways to do it all the time, using commands like YUM and i’m getting confused.
Can someone possibly, in plain, simple black and white instructions, explain the process so I can simply run code like this
try {
$hostname = "myhostname";
$port = myportnumber;
$dbname = "databasename";
$username = "user";
$pw = "password";
$dbh = new PDO ("dblib:host=$hostname:$port;dbname=$dbname","$username","$pw");
} catch (PDOException $e) {
echo "Failed to get DB handle: " . $e->getMessage() . "n";
exit;
}
When I load my page where this command is located i get the error message
‘Failed to get DB handle: could not find driver’
Thanks
2
Answers
Example of installing
pdo_dblib
on CentOS-like OS for Plesk PHP5.6
:On line #37 replace:
with:
Save file and:
you should see something like
Enable extension:
Verify:
Now sites in Plesk with PHP handler 5.6 will work with:
Pay attention for :
PHP DBlib PDO Issue
How to connect MSSQL from PHP 7, Plesk 12.5 installed on CentOS 7
PHP PDO works in OOPS .
Hence in PHP PDO first you must create a database handler using PDO class which is already defined in PHP Library. which will work as object for your database queries.
When you connect your database using PDO Class than you are ready to play with your queries with the database handler which you got during PDO connection.
Here $dbh will works as database handler object for MySQL Queries Operations.
I have a personal blog for PHP PDO here . Just go to reference and take a look how queries are working . Finally i would like to say it’s very simple and secure.