Created
July 24, 2017 03:23
-
-
Save chihirokaasan/718c23c0b8b4509dba1db8950037ce1d to your computer and use it in GitHub Desktop.
PHPからMySQLへ繋ぐ際のサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$dsn = 'mysql:host=172.17.0.2;dbname=your-database-name'; | |
$username = 'root'; | |
$password = 'your-root-password'; | |
$options = array( | |
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8', | |
); | |
$dbh = new PDO($dsn, $username, $password, $options); | |
$sql = "SELECT * FROM Table"; | |
$stmt = $dbh->query($sql); | |
var_dump($stmt); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment