LoginSignup
2
0

More than 5 years have passed since last update.

PHPの対話モードでサクッとDBとの疎通確認をする

Last updated at Posted at 2018-03-09

Webサーバー上でDBと疎通してるのか確認したい時ありますよね。

でも、Webサーバーにmysqlクライアントが無い事も多いですよね。

そんな時でもPHPなら対話モードを使ってサクッと確認出来ちゃいます

  • 対話モード開始
$ php -a
  • コード
$db = new PDO('mysql:dbname=test;host=xxx.xxxx.xxx.xxx', 'user', 'password');
$ret = $db->query('select * from users');
$row = $ret->fetch(PDO::FETCH_ASSOC);
print_r($row);

いざ、アプリケーションをリリースしたらDBの接続エラーで動かない!
なんてかっこ悪い事態は未然に防ぎましょう

2
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
2
0