概要
webarenaでubuntu18.04やってみた。
mysql5.7やってみた。
crudやってみた。
Create
<?php
$db = new PDO("mysql:host=localhost;dbname=mydb;", 'arena', 'pass');
$sql = 'insert into test values(null, "name", 20, now())';
$res = $db->query($sql);
if ($res) print "ok\n";
?>
Read
<?php
$db = new PDO("mysql:host=localhost;dbname=mydb;", 'arena', 'pass');
$sql = 'select * from test';
$res = $db->query($sql);
if ($res) print "ok\n";
?>
Update
<?php
$db = new PDO("mysql:host=localhost;dbname=mydb;", 'arena', 'pass');
$sql = 'update test set age=80 where id=1';
$res = $db->query($sql);
if ($res) print "ok\n";
?>
Delete
<?php
$db = new PDO("mysql:host=localhost;dbname=mydb;", 'arena', 'pass');
$sql = 'delete from test where id=1';
$res = $db->query($sql);
if ($res) print "ok\n";
?>
以上。