query($Sql); $row = $statement->fetch(PDO::FETCH_ASSOC); return htmlentities($row['access_count']); } function db_insert(&$connection,$ip, $url){ $Sql = "INSERT INTO access_log (access_date,ip,url) VALUES(now(),'".$ip."','".$url."')"; $statement = $connection->query($Sql); } function db_open(&$connection){ // データベースに接続 $connection = new PDO('mysql:host=localhost;dbname=mydb', 'myuser', 'segm'); if (!$connection){ die('データベースに接続できません:'. mysql_error()); } } function db_close(&$connection){ // データベースから切断する unset($connection); } ?>