public function setUp() { $this->db = QPDB::getBaseDB(); $this->db->exec('CREATE TABLE IF NOT EXISTS qpdb_test (colOne, colTwo, colThree)'); $stmt = $this->db->prepare('INSERT INTO qpdb_test (colOne, colTwo, colThree) VALUES (:one, :two, :three)'); for ($i = 0; $i < 5; ++$i) { $vals = array(':one' => 'Title ' . $i, ':two' => 'Body ' . $i, ':three' => 'Footer ' . $i); $stmt->execute($vals); $stmt->closeCursor(); } }
<?php /** * Use QueryPath's database extension to import XML data into a database. * * * @author M Butcher <*****@*****.**> * @license LGPL The GNU Lesser GPL (LGPL) or an MIT-like license. */ require_once '../src/QueryPath/QueryPath.php'; require_once '../src/QueryPath/Extension/QPDB.php'; // Set the default database. QPDB::baseDB('sqlite:../test/db/qpTest.db'); // To begin, let's create a new database. We can do this outside // of QueryPath: $db = QPDB::getBaseDB(); $db->exec('CREATE TABLE IF NOT EXISTS qpdb_article (title, author, body)'); // Here's our sample article: $article = '<?xml version="1.0"?> <article> <title>Use QueryPath for Fun and Profit</title> <author> <first>Matt</first> <last>Butcher</last> </author> <body> <![CDATA[ <p>QueryPath is a great tool.</p> <p>Use it in many ways.</p> ]]> </body>