File: dbeng_pdo_sqlite.php

package info (click to toggle)
spotweb 20130826%2Bdfsg2-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,132 kB
  • ctags: 11,281
  • sloc: php: 31,367; xml: 1,009; sh: 148; makefile: 83
file content (32 lines) | stat: -rwxr-xr-x 782 bytes parent folder | download | duplicates (2)
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