View sourcecode

The following files exists in this folder. Click to view.

pdo.php

1 lines ASCII Unix (LF)
1
<?php
error_reporting(-1);

$tmp = "";
if (isset($_GET['tmp'])) {
  $tmp="/tmp/";
}

unlink("{$tmp}pdo.sqlite");

$dsn = "sqlite:{$tmp}pdo.sqlite";
 
echo "<pre>Creating database $dsn on " . gethostname() . "\n";
try {
  $db = new PDO($dsn);
  $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
  echo "Failed to connect to the database using DSN:<br>$dsn<br>";
  throw $e;
}

echo "Creating table\n";
$sql = "create table a (a int);";

echo " preparing\n";
$stmt = $db->prepare($sql);

echo " executin\n";
$stmt->execute();

$sql = "select * from a;";

echo "Selecting from database\n";
echo " preparing\n";
$stmt = $db->prepare($sql);

echo " executing\n";
$stmt->execute();