<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet href="_c74_vig.xsl" type="text/xsl"?>
<vignette name="The SQLite Object" package="Max">
<h1>
The SQLite Object
</h1>
<p>
The SQLite object provides access to the SQLite database system (see http://www.sqlite.org for more information). A companion object, SQLResult, is required for most database operations.
</p>
<h2>SQLite Constructor</h2>
<code language="javascript">var sqlite = new SQLite;
</code>
<p>
No arguments are required for the instantiation of an SQLite object. However, all future calls to the database will be through this instance of the object.
</p>
	<jsmethod_list name="SQLite Methods">
  		<jsmethod name="open">
		    <arglist>
		    	<arg name="filename" type="String"/>
		    	<arg name="on_disk" type="Number"/>
		    	<arg name="must_exist" type="Number"/>
		    </arglist>
		    <description>
		    	Open an SQLite-format file for database operations. The required filename argument is the file to access. The optional <i>on_disk</i> argument determines if the file should be memory-based (0) or disk-based (1). The optional <i>must_exist</i> argument, if non-zero, requires the file to exist to be opened. If zero, then a file will be created if it does not exist.
			    <p>
				This method returns an error code if unsuccessful, or a zero if the call results in an opened database.
				</p>
		    </description>
  		</jsmethod>
  		<jsmethod name="close">
		    <description>
		    	Closes a previously opened SQLite database.
		    </description>
  		</jsmethod>

  		<jsmethod name="exec">
		    <arglist>
		    	<arg name="command" type="String"/>
		    	<arg name="result" type="String"/>
		    </arglist>
		    <description>
		    	Perform an SQL command on the database. This command must be in standard SQL language syntax, limited to the operations that SQLite supports. The result argument will return with an SQLResult object (see below) with any applicable results.
		    	<p>
				The method returns an error code if unsuccessful, or a zero if the call results in a completed operation.
				</p>
				<p>
				<b>Example:</b>
				</p>
				<code language="javascript">
var res = new SQLResult;
var rtn = sqlite.exec(“CREATE TABLE Persons (PersonID INTEGER, LastName TEXT, FirstName TEXT);”, res);
				</code>
		    </description>
  		</jsmethod>

  		<jsmethod name="begintransaction">
		    <description>
		    	Start an SQL transaction on the database. This allows you to batch database updates, and to roll back sets of changes if they do not all complete. When you are done with batch updates, a call to <b>endtransaction</b>() should be executed.
		    </description>
  		</jsmethod>

  		<jsmethod name="endtransaction">
		    <description>
		    	Complete a transaction and flush all database writes to the file.
		    </description>
  		</jsmethod>
  	</jsmethod_list>
</vignette>
