-
-
Notifications
You must be signed in to change notification settings - Fork 117
Expand file tree
/
Copy pathsqlite.php
More file actions
90 lines (83 loc) · 1.5 KB
/
sqlite.php
File metadata and controls
90 lines (83 loc) · 1.5 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
function sqlite_exists()
{
return( (PHP_VERSION_ID < 50400) ? function_exists("sqlite_open") : class_exists("SQLite3", false) );
}
function sqlite_open1($filename, $mode, &$error_msg)
{
if (PHP_VERSION_ID < 50400)
{
$dbhandle = sqlite_open($filename, $mode, $error_msg);
}
else
{
try
{
$dbhandle = new SQLite3($filename);
}
catch (Exception $exception)
{
$error_msg = $exception->getMessage();
}
}
return $dbhandle;
}
function sqlite_close1($dbhandle)
{
if (PHP_VERSION_ID < 50400)
{
sqlite_close($dbhandle);
}
else
{
$dbhandle->close();
}
}
function sqlite_exec1($dbhandle, $query, &$error_msg)
{
if (PHP_VERSION_ID < 50400)
{
@sqlite_exec($dbhandle, $query, $error_msg);
}
else
{
try
{
@$dbhandle->exec($query);
}
catch (Exception $exception)
{
$error_msg = $exception->getMessage();
}
}
}
function sqlite_query1($dbhandle, $query, &$error_msg)
{
$result = '';
if (PHP_VERSION_ID < 50400)
{
$res = sqlite_unbuffered_query($dbhandle, $query, SQLITE_ASSOC, $error_msg);
if($res!==false)
$result = strval(sqlite_fetch_single($res));
}
else
{
try
{
$result = strval($dbhandle->querySingle($query));
}
catch (Exception $exception)
{
$error_msg = $exception->getMessage();
}
}
return $result;
}
function sqlite_escape_string1($item)
{
return( (PHP_VERSION_ID < 50400) ? sqlite_escape_string($item) : SQLite3::escapeString($item) );
}
function sqlite_db_name()
{
return( (PHP_VERSION_ID < 50400) ? "peers.dat" : "peers3.dat" );
}