2808 explained code solutions for 75 technologies


php-pdoConnect to MariaDB using PHP PDO


Since MariaDB is fully compatible with Mysql, using it with PDO is the same as Mysql.

try {
  $pdo = new PDO('mysql:host=localhost;dbname=test', 'user', 'pwd');
} catch ( PDOException $e ) {
  die($e->getMessage());
}ctrl + c
$pdo

PDO connection object

new PDO

create new PDO connection

PDOException $e

exception will be thrown if connection failed

mysql:

connect to MariaDB using Mysql protocol