PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php error_reporting(E_ALL); $db = $pdo; $db -> setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->exec("CREATE TABLE IF NOT EXISTS book ( id INTEGER PRIMARY KEY, name text, amount integer, day text ); "); $stmt = $db->prepare('insert into book(name,amount,day) values(:name,:amount,:day)'); $stmt->bindValue(':name', 'foo', SQLITE3_TEXT); $stmt->bindValue(':amount', 102, SQLITE3_INTEGER); $stmt->bindValue(':day', '2022-12-28', SQLITE3_TEXT); $stmt->execute(); $result = $db->query("select * from book where `name`='foo'"); foreach($result as $r){ print $r['name']."\n"; }
Show:  
Copy Clear