public function flush() { $ses = session_id(); $tbl = static::table(); $sql = "DELETE FROM {$tbl} WHERE parent='0' AND (session='{$ses}' OR expires < NOW() OR expires IS NULL)"; schemadb::execute('query', $sql); }
public static function clear() { $ses = session_id(); $tbl = static::table(); $sql = "DELETE FROM {$tbl} WHERE parent='0' AND session='{$ses}'"; schemadb::execute('query', $sql); }
public function store_insert($force = false) { ## static::schemadb_update(); ## $c = []; $v = []; $k = static::primary_key(); ## foreach (static::skema() as $f => $d) { ## if ($f == $k && !$force) { continue; } ## $a = $this->{$f}; $t = gettype($a); ## switch ($t) { ## case 'double': $a = number_format($a, 2, '.', ''); break; ## ## case 'array': schemadb::object_build($d, $a, $r); $a = $r; break; } ## $a = schemadb::escape($a); ## $c[] = $f; $v[] = "'" . $a . "'"; } ## $c = implode(',', $c); $v = implode(',', $v); ## $t = static::table(); $q = "INSERT INTO {$t} ({$c}) VALUES ({$v})"; ## schemadb::execute('query', $q); ## if ($k) { $i = schemadb::execute('last_id'); $this->{$k} = $i; return $i; } else { return true; } }