1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
<?php
class dbeng_pdo_sqlite extends dbeng_pdo {
private $_db_path;
protected $_conn;
function __construct($path) {
$this->_db_path = $path;
/*
* sqlite does not support batch inserts
*/
$this->_batchInsertChunks = 1;
} # ctor
function connect() {
try {
if (!$this->_conn instanceof PDO) {
$this->_conn = new PDO('sqlite:' . $this->_db_path);
$this->_conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} # if
} catch(PDOException $e) {
throw new DatabaseConnectionException($e->getMessage(), -1);
} # catch
} # connect()
function safe($s) {
return SQLite3::escapeString($s);
// sqlite module is deprecated in more recnt PHP versions, hence wont work
// return sqlite_escape_string($s);
} # safe
} # class
|