<?php

/*

sqlite3 ~/developpement/tests/temp/spidermonkey/test-3/db-1.sqlite

create table user (id integer primary key autoincrement, nom varchar(64), email varchar(128));
insert into user (nom, email) values ('Test1', 'test1@example.com');
insert into user (nom, email) values ('Test2', 'test2@example.com');
insert into user (nom, email) values ('Test3', 'test3@example.com');


*/


$dsn = 'sqlite:' . __DIR__ . '/db-1.sqlite';
$pdo = new PDO($dsn);

/*
$result = $pdo->query('select * from user');
foreach ($result as $row) {
    var_dump($row);
}
*/



$ctx = new JSContext();

$ctx->assign('pdo', $pdo);

$js = file_get_contents(__DIR__ . '/test.js');
echo '<pre>' . htmlspecialchars($js) . '</pre>';

$a = $ctx->evaluateScript($js);
var_dump($a);

