Permalink
Browse files

added connect to memcached sample

  • Loading branch information...
koni committed Dec 30, 2018
1 parent a307747 commit 19a851fd819388a7f6282a9e7e0f090418ef77a9
Showing with 19 additions and 2 deletions.
  1. +19 −2 public/index.php
@@ -1,6 +1,11 @@
<?php
error_reporting(E_ALL);
echo "Hello! World!<br>";
echo "<h1>docker-php-nginx-mysql-memcached</h1>";
$now = date('Y-m-d H:i:s');
echo "<h2>Connect to MySQL</h2>";
$mysql = new mysqli($_ENV['DATABASE_HOST'], $_ENV['DATABASE_USER'],
$_ENV['DATABASE_PASSWORD'], $_ENV['DATABASE_NAME']);
@@ -11,7 +16,7 @@
exit;
}
$sql = "INSERT INTO hoges(created_at) VALUES('" . date('Y-m-d H:i:s') . "')";
$sql = "INSERT INTO hoges(created_at) VALUES('" . $now . "')";
$result = $mysql->query($sql);
@@ -23,4 +28,16 @@
mysqli_close($mysql);
echo "<h2>Connect to memcached</h2>";
$m = new Memcached();
$m->addServer('memcached', 11211);
var_dump($m->get('foo'));
$m->set('foo', $now);
var_dump($m->get('foo'));
echo "<div><a href='https://github.com/koni/docker-php-nginx-mysql-memcached'>koni/docker-php-nginx-mysql-memcached</a></div>";
echo "<hr />";
phpinfo();

0 comments on commit 19a851f

Please sign in to comment.