Is it possible to do something like
Class.forName("com.mysql.jdbc.Driver");
to
$pdo = new PDO("java:com/PakageName/jdbc/Driver");
by adding some .jar files in php project library?
I have made a simple PHP project and want to connect a database remotely which is providing JDBC driver. Java program works fine but PDO will allow this ?
JDBC
is only for JAVA database connectivity. Here PHP can use ODBC
Connection with PDO_ODBC. ( Go through with the documentation )
PDO_ODBC is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to databases through ODBC drivers.
Example:
<?php
$dbh= new PDO('odbc:SOURCENAME', 'username', 'password');
$stmt = $dbh->prepare("$query");
$stmt->execute();
while ($row = $stmt->fetch()) {
print_r($row);
}
unset($dbh); unset($stmt);
?>
Useful link: http://php.net/manual/en/pdo.drivers.php