1 |
<?php |
1 |
<?php |
2 |
|
2 |
|
3 |
/** |
3 |
/** |
4 |
* IO class. |
4 |
* IO class. |
5 |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
5 |
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License |
6 |
* @copyright (c)2003, 2004 Tamlyn Rhodes |
6 |
* @copyright (c)2003, 2004 Tamlyn Rhodes |
7 |
* @version $Id: io_sqlite.class.php,v 1.4 2005/11/30 23:02:18 tamlyn Exp $ |
7 |
* @version $Id: io_sqlite.class.php,v 1.4 2005/11/30 23:02:18 tamlyn Exp $ |
8 |
*/ |
8 |
*/ |
9 |
|
9 |
|
10 |
//include the generic SQL class |
10 |
//include the generic SQL class |
11 |
require_once dirname(__FILE__)."/iosql.class.php"; |
11 |
require_once dirname(__FILE__)."/iosql.class.php"; |
12 |
|
12 |
|
13 |
/** |
13 |
/** |
14 |
* Class used to read and write data to and from a SQLite database. |
14 |
* Class used to read and write data to and from a SQLite database. |
15 |
* @package singapore |
15 |
* @package singapore |
16 |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
16 |
* @author Tamlyn Rhodes <tam at zenology dot co dot uk> |
17 |
* @copyright (c)2004 Tamlyn Rhodes |
17 |
* @copyright (c)2004 Tamlyn Rhodes |
18 |
*/ |
18 |
*/ |
19 |
class sgIO_sqlite extends sgIOsql |
19 |
class sgIO_sqlite extends sgIOsql |
20 |
{ |
20 |
{ |
21 |
/** |
21 |
/** |
22 |
* Database resource pointer |
22 |
* Database resource pointer |
23 |
*/ |
23 |
*/ |
24 |
var $db; |
24 |
var $db; |
25 |
|
25 |
|
26 |
/** |
26 |
/** |
27 |
* @param sgConfig pointer to a {@link sgConfig} object representing |
27 |
* @param sgConfig pointer to a {@link sgConfig} object representing |
28 |
* the current script configuration |
28 |
* the current script configuration |
29 |
*/ |
29 |
*/ |
30 |
function sgIO_sqlite() |
30 |
function sgIO_sqlite() |
31 |
{ |
31 |
{ |
32 |
$this->config =& sgConfig::getInstance(); |
32 |
$this->config =& sgConfig::getInstance(); |
33 |
$this->db = sqlite_open($this->config->base_path.$this->config->pathto_data_dir."sqlite.dat"); |
33 |
$this->db = sqlite_open($this->config->base_path.$this->config->pathto_data_dir."sqlite.dat"); |
34 |
} |
34 |
} |
35 |
|
35 |
|
36 |
/** |
36 |
/** |
37 |
* Name of IO backend. |
37 |
* Name of IO backend. |
38 |
*/ |
38 |
*/ |
39 |
function getName() |
39 |
function getName() |
40 |
{ |
40 |
{ |
41 |
return "SQLite"; |
41 |
return "SQLite"; |
42 |
} |
42 |
} |
43 |
|
43 |
|
44 |
/** |
44 |
/** |
45 |
* Version of IO backend. |
45 |
* Version of IO backend. |
46 |
*/ |
46 |
*/ |
47 |
function getVersion() |
47 |
function getVersion() |
48 |
{ |
48 |
{ |
49 |
return "$Revision: 1.4 $"; |
49 |
return "$Revision: 1.4 $"; |
50 |
} |
50 |
} |
51 |
|
51 |
|
52 |
/** |
52 |
/** |
53 |
* Author of IO backend. |
53 |
* Author of IO backend. |
54 |
*/ |
54 |
*/ |
55 |
function getAuthor() |
55 |
function getAuthor() |
56 |
{ |
56 |
{ |
57 |
return "Tamlyn Rhodes"; |
57 |
return "Tamlyn Rhodes"; |
58 |
} |
58 |
} |
59 |
|
59 |
|
60 |
/** |
60 |
/** |
61 |
* Brief description of IO backend and it's requirements. |
61 |
* Brief description of IO backend and it's requirements. |
62 |
*/ |
62 |
*/ |
63 |
function getDescription() |
63 |
function getDescription() |
64 |
{ |
64 |
{ |
65 |
return "Uses a SQLite database. Requires only the SQLite PHP extension which incorporates the database server."; |
65 |
return "Uses a SQLite database. Requires only the SQLite PHP extension which incorporates the database server."; |
66 |
} |
66 |
} |
67 |
|
67 |
|
68 |
function query($query) |
68 |
function query($query) |
69 |
{ |
69 |
{ |
70 |
return sqlite_query($this->db, $query); |
70 |
return sqlite_query($this->db, $query); |
71 |
} |
71 |
} |
72 |
|
72 |
|
73 |
function escape_string($query) |
73 |
function escape_string($query) |
74 |
{ |
74 |
{ |
75 |
return sqlite_escape_string($query); |
75 |
return sqlite_escape_string($query); |
76 |
} |
76 |
} |
77 |
|
77 |
|
78 |
function fetch_array($res) |
78 |
function fetch_array($res) |
79 |
{ |
79 |
{ |
80 |
return sqlite_fetch_array($res); |
80 |
return sqlite_fetch_array($res); |
81 |
} |
81 |
} |
82 |
|
82 |
|
83 |
function num_rows($res) |
83 |
function num_rows($res) |
84 |
{ |
84 |
{ |
85 |
return sqlite_num_rows($res); |
85 |
return sqlite_num_rows($res); |
86 |
} |
86 |
} |
87 |
|
87 |
|
88 |
function error() |
88 |
function error() |
89 |
{ |
89 |
{ |
90 |
return sqlite_error_string(sqlite_last_error($this->db)); |
90 |
return sqlite_error_string(sqlite_last_error($this->db)); |
91 |
} |
91 |
} |
92 |
|
92 |
|
93 |
} |
93 |
} |
94 |
|
94 |
|
95 |
?> |
95 |
?> |