Modules
ADT Database GTK2 GUI IP PiJAX Public Sql Stdio Subversion System Tools Xosd lua v4l2 wx
Recent Changes
Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0
Popular Downloads
Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48
|
Module Information
Sql.Provider.SQLite
Viewing contents of Sql_Provider_SQLite-1.8/module.pmod.in
#pike __REAL_VERSION__
constant __author = "Bill Welliver ";
constant __version = "1.8";
//! an interface to the SQLite SQL Database Library (www.sqlite.org)
class SQLite {
inherit .___SQLite.SQLite;
void create(mixed ... args)
{
#ifdef __NT__
::create(args*"\\");
#else
::create(args*"/");
#endif
}
object|int big_query(object|string q, mapping(string|int:mixed)|void bindings)
{
if(!bindings)
return ::big_query(q);
else
return ::big_query(Sql.sql_util.emulate_bindings(q, bindings, this));
}
array query(object|string q, mapping(string|int:mixed)|void bindings)
{
if(!bindings)
return ::query(q);
else
return ::query(Sql.sql_util.emulate_bindings(q, bindings, this));
}
array list_fields(string n, string|void wild)
{
string qry = "";
qry = "PRAGMA table_info(" + n + ")";
array r = query(qry);
// now, we weed out the ones that don't match wild, if provided
if(wild)
{
r = filter(r, lambda(mapping row)
{ return (search(row->name, wild) !=-1); }
);
}
array fields = ({});
foreach(r;; mapping f)
{
mapping fld = ([]);
fld->name = f->name;
fld->table = n;
string t, l;
if(!sscanf(f->type, "%s(%s)", t, l))
t = f->type;
fld->length = (int)l;
switch(t)
{
case "char":
t = "string";
break;
case "int":
t = "integer";
break;
}
fld->type = t;
fld->flags = (<>);
if((int)f->notnull)
fld->flags->not_null = 1;
if((int)f->pk)
{
// primary key implies not null.
fld->flags->not_null = 1;
fld->flags->primary_key = 1;
}
fld->default = f->dflt_value;
fields += ({fld});
}
return fields;
}
array list_tables(string|void n)
{
string qry = "";
if(n)
qry = "SELECT name FROM SQLITE_MASTER WHERE name like '" + n + "%' and TYPE='table'";
else
qry = "SELECT name FROM SQLITE_MASTER where TYPE='table'";
array r = query(qry);
array out = ({});
foreach(r;;mapping row)
{
if(row->name)
out += ({row->name});
else
out += ({row["sqlite_master.name"] });
}
return out;
}
}
|
|
|