0
0

More than 1 year has passed since last update.

phpsandboxのdb(sqlite)接続設定のメモ

Last updated at Posted at 2022-11-04

概要

phpsandboxでsqliteに接続確認

執筆理由

phpsandboxのdb(sqlite)接続について、記事が見当たらなかったため。

phpsandboxのsqlite接続確認

画面からも確認できるが、
/var/www/database.sqlite
にあるので、sqlite接続確認

<?php

try {
    $pdo = new PDO('sqlite:/var/www/database.sqlite');
    $msg = "MySQL への接続確認が取れました。";
}catch (PDOException $e){
    $isConnect = false;
    $msg       = "MySQL への接続に失敗しました。<br>(" . $e->getMessage() . ")";
}

?>

<html>
<head>
    <meta charset="utf-8">
    <title>Welcome to PHPSandbox</title>
</head>
<body>
<div class="h-screen bg-white flex items-center justify-center font-sans text-gray-700" style="font-family: 'Jost', sans-serif">
    <h1>MySQL接続確認</h1>
    <p><?php echo $msg; ?></p>
</div>
</body>
</html>

結果

何回か読み込みなおしたり、$msgに値を入れなおしたりすると表示するかもしれません

sandbox接続.png

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