SQLiteµÄ·â×°Àà
package
{
import flash.data.SQLConnection;
import flash.data.SQLResult;
import flash.data.SQLStatement;
import flash.errors.SQLError;
import flash.events.SQLErrorEvent;
import flash.events.SQLEvent;
import flash.filesystem.File;
import mx.collections.ArrayCollection;
public class DBUtil
{
/**
* Êý¾Ý¿â²Ù×÷Àà±ð
**/
private const typeArr:Array = ['select','insert','update','delete','create','alter','drop'];
/**
* Á¬½Ó
**/
private var conn:SQLConnection;
/**
* ÉùÃ÷
**/
private var stmt:SQLStatement;
/**
* ½á¹û¼¯ºÏ
**/
private var rsAC:ArrayCollection;
public function DBUtil()
{
}
/**
* »ñµÃÁ¬½Ó
**/
private function getConn():SQLConnection
{
if(this.conn == null){
conn = new SQLConnection();
conn.addEventListener(SQLEvent.OPEN, sqlOpen);
conn.addEventListener(SQLErrorEvent.ERROR, sqlError);
}
return this.conn;
}
/**
* ¹Ø±ÕÁ¬½Ó
**/
private function closeConn():void
{
if(this.conn != null){
this.conn.close();
this.conn = null;
}
}
/**
* »ñµÃÉùÃ÷
**/
private function getStatement():SQLStatement
{
if(this.stmt == null)
{
stmt = new SQLStatement();
stmt.sqlConnection = getConn();
stmt.addEventListener(SQLErrorEvent.ERROR, sqlError);
}
return this.stmt;
}
/**
* ¹Ø±ÕÉùÃ÷
**/
private functio
Ïà¹ØÎĵµ£º
1 TOP
ÕâÊÇÒ»¸ö´ó¼Ò¾³£Îʵ½µÄÎÊÌ⣬ÀýÈçÔÚSQLSERVERÖпÉÒÔʹÓÃÈçÏÂÓï¾äÀ´È¡µÃ¼Ç¼¼¯ÖеÄǰʮÌõ¼Ç¼£º
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
µ«ÊÇÕâÌõSQLÓï¾äÔÚSQLiteÖÐÊÇÎÞ·¨Ö´Ðеģ¬Ó¦¸Ã¸ÄΪ£º
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
ÆäÖÐlimit 0,10±íʾ´ÓµÚ0Ìõ¼Ç¼¿ªÊ¼£¬Íùºó ......
°²×°:
¹Ù·½ÍøÕ¾ÏÂÔØ×îеÄsqlite°æ±¾
¹Ù·½ÍøÕ¾: http://www.sqlite.org/
ÏÂÔØµØÖ·Îª: http://www.sqlite.org/download.html
¹Ù·½µÄÏÂÔØÒ³ÃæÌṩÁËºÜ¶à°æ±¾µÄÏÂÔØ…ÕâÀï½éÉÜÒ»ÏÂ;
Source Code: Ô´´úÂë°æ±¾µÄÏÂÔØ
Documentation: Ïà¹ØÎĵµ
Precompiled Binaries for Linux / Precompiled Binaries For Mac ......
@ǶÈëʽ¹ØÏµÐÍÊý¾Ý¿âSQLite
ÌØµã
1.Ö§³ÖÎåÖÖÊý¾ÝÀàÐÍ null,INTEGER,REAL(¸¡µãÊý),TEXT(×Ö·û´®Îı¾)ºÍBLOB£¨¶þ½øÖÆÎı¾£©Êý¾ÝÀàÐÍ£¬ËäÈ»
ËüÖ»ÓÐÎåÖÖ£¬µ«Êµ¼ÊÉÏsqlite3Ò²½ÓÊÖvarcher(n),char(n),decimal(p,s)µÈÊý¾ÝÀàÐÍ£ ......