SQLite

Lets you create and manipulate SQLite databases.

Summary
Lets you create and manipulate SQLite databases.
Opens a database.
Closes the database and renders this instance of SQLite useless.
Returns the row id of the last successful insert.
Executes the given query and returns an array of rows.
Executes a statement and does not return any results.
Returns raw data for the first column in the first row returned by the query.

Functions and Properties

SQLite

SQLite(string fileName)

Opens a database.

parameters

fileNameThe name of the file containing the database.

close

close()

Closes the database and renders this instance of SQLite useless.

lastInsertRowId

int lastInsertRowId readonly

Returns the row id of the last successful insert.  See http://sqlite.org/c3ref/last_insert_rowid.html

select

jsval select(string query)

Executes the given query and returns an array of rows.  The first array will contain the column names.

parameters

queryA query to execute (usually a SELECT statement).

returns

An array of string arrays.  The first array is the column names, the rest are all the values.  If there is an error, it returns NULL.  If the query returned no rows, an empty array is returned.

example

db.select( "SELECT First , Last FROM ABPerson" );

returns

[ [ "First" , "Last" ] , [ "John" , "Doe" ] , [ "Madonna" , null ] ]

execute

bool execute(string statement)

Executes a statement and does not return any results.

parameters

statementA SQL statement to execute.

returns

trueFor success.
falseOtherwise.

dataFromField

Data dataFromField(string query)

Returns raw data for the first column in the first row returned by the query.  You should typically use a query that returns a single row and a single column.

parameters

queryA SQL query.

returns

dataA data instance containing the raw bytes of the field.
nullIf there was a problem.

example

var imageData = imageDB.dataFromField( "select data from ABImage where record_id = 148 and format = 0" );
var image = Images.imageWithData( imageData );
var imageView = new UIImageView( image );
SQLite(string fileName)
Opens a database.
close()
Closes the database and renders this instance of SQLite useless.
int lastInsertRowId readonly
Returns the row id of the last successful insert.
jsval select(string query)
Executes the given query and returns an array of rows.
bool execute(string statement)
Executes a statement and does not return any results.
Data dataFromField(string query)
Returns raw data for the first column in the first row returned by the query.