PHP, PDO and Database platforms

Site Admin
Posts: 88
Joined: Tue Jan 31, 2006 3:10 pm
Location: Moss Norway

PHP, PDO and Database platforms

Postby KBleivik » Wed Dec 12, 2007 11:14 am

PDO is the new PHP Data Object extension introduced with PHP 5.0 that is much safer than the traditional model since the connection to the data base server is encapsulated. Communication with the data base server takes place through the PDO object.

PHP supports all the important relational databases including Oracle, IBM's DB2, Microsoft's SQL Server and Sybase to name a few. It also supports the open software database platforms like SQLite, PostgreSQL and MySQL.

Example: Connecting to a MySQL data base server.

Code: Select all

$dsn = 'mysql:host=hostName; dbname=databasName;';
$Password ='passWord';
$dbh = new PDO($dsn, $user, $password);
catch (PDOException $e)
echo 'Connection failied: ' . $e->getMessage();

Kjell Gunnar Bleivik
Make it simple, as simple as possible but no simpler: | |

Return to “MySQL, PHP and phpMyAdmin”

Who is online

Users browsing this forum: No registered users and 1 guest