PDOとは
PHP Data Objectsrの略称
PHPからデータベースのアクセスを抽象的にしてくれるもの
PHPからMySQLに接続するコード例(SELECT文)
<?php
$mysql = 'mysql:host=localhost;dbname=xxxxxx,charet=utf8';
//xxxxxx === 自分のmysql中の接続したいデータベース名
$user = 'xxxxxx';
//xxxxxx === 自分のmysqlユーザー名
$passwoad = 'xxxxxx';
//xxxxxx === 自分のmysqlパスワード
try {
$db = new PDO($mysql, $user, $passwoad);
$select = "SELECT * FROM" ;
$res = $db->query($select);
} catch (PDOException $e) {
echo '接続エラー: ' . $e->getMessage();
}
?>