LoginSignup
1
0

More than 5 years have passed since last update.

PHP(PDO) でかんたん mysql 接続

Last updated at Posted at 2018-02-06
/**
 * DB接続
 */
function pdo_connect() {
  // PDO
  try {
    $connection = new PDO('mysql:host=localhost;dbname=test', 'root', 'password');
  }
  catch (PDOException $e) {
    exit('データベース接続失敗。'.$e->getMessage());
  }

  return $connection;
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0