[PDO]디비 연결

PHP 2020. 2. 13. 09:52

<?php
try {
	$pdo = new PDO("mysql:host=localhost; dbname=DBNAME; charset=utf8", "ID", "PASSWORD", [
		PDO::MYSQL_ATTR_FOUND_ROWS => true,
		PDO::ATTR_EMULATE_PREPARES => true,
		PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
		PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
	]);
} catch(PDOException $e) {
	die("Connection Failed : ".$e->getMessage());
}

 

댓글 0