Upgrade to sqlite3

This commit is contained in:
sandbender
2010-11-14 00:15:26 +01:00
parent 5098db94eb
commit 95d8ede9ac
5 changed files with 17 additions and 19 deletions

View File

@@ -4,10 +4,9 @@ require_once("lib/db.php");
function macs_get() {
$results = array();
$db = get_db();
$q = sqlite_query($db, "select mac from macs where committime > strftime('%s','now') - ".MACFILE_TTL);
$q = $db->query("select mac from macs where committime > strftime('%s','now') - ".MACFILE_TTL);
if (!$q) return $results;
while(sqlite_has_more($q)) {
$row = sqlite_fetch_array($q, SQLITE_ASSOC);
while($row = $q->fetch_array(SQLITE_ASSOC)) {
$results[] = $row['mac'];
}
return $results;
@@ -15,11 +14,11 @@ function macs_get() {
function macs_add($mac) {
$db = get_db();
$mac = sqlite_escape_string($mac);
return sqlite_exec($db, "insert or replace into macs values (\"$mac\", strftime('%s','now'))");
$mac = $db->escape_string($mac);
return $db->exec("insert or replace into macs values (\"$mac\", strftime('%s','now'))");
}
function macs_purge() {
$db = get_db();
return sqlite_exec($db, "delete from macs where committime <= strftime('%s','now') - ".MACFILE_TTL);
return $db->exec("delete from macs where committime <= strftime('%s','now') - ".MACFILE_TTL);
}