0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

paiza.ioでSQL

Last updated at Posted at 2017-03-12

概要

paiza.ioでSQLやってみた。
phpでPDO使って、sqliteでやってみた。

成果物

サンプルコード

<?php
$db = new PDO("sqlite:test.db");
$sql = "create table bbs(id integer primary key autoincrement, 名前 text, 投稿時間 integer, 本文 text)";
$db->query($sql);
$sql = "insert into bbs(名前, 投稿時間, 本文) values ('名無しさん', 123456789, 'こんにちは')";
$db->query($sql);
$sql = "select * from bbs";
foreach ($db->query($sql) as $line) 
{
    print "{$line['id']} {$line['名前']} {$line['投稿時間']} {$line{'本文'}}\n";
}
?>
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?