With the proviso that not I've tried this as yet and it's entirely off the top of my head, it should go something like this ...
// saving //
var userVO:UserVO = new UserVo("jim","hayes");
// save object into byteArray
var userVOasByteArray:ByteArray = new ByteArray();
userVOasByteArray.writeObject(userVO);
// save the byteArray to the database - usual sqlite code excluded for brevity
var query:String = "INSERT INTO tbl_Users (user) VALUES (:userVOasByteArray);
sqlStatement.parameters[":userVOasByteArray"] = userVOasByteArray;
sqlStatement.text = query;
sqlStatement.execute();
// retrieve userVO from database
var userID:int = 1;
var query:String = "SELECT user from tbl_users WHERE user_id = :userID"
sqlStatement.parameters[":userID"] = userID;
// execute, get results etc
You should end up with a byteArray, which contains your object, so you need to
read that out :
yourByteArray.position = 0;
var userVO:UserVO = yourByteArray.readObject() as UserVO;
This assumes that the user filed in your db is a blob type.
Note that any of the syntax above may well be incorrect, but hopefully is not
too far off...
-----Original Message-----
From: [email protected] on behalf of markflex2007
Sent: Mon 25/08/2008 04:18
To: [email protected]
Subject: [flexcoders] Re: How to save object to SQLite and get it back?
I only confuse saving/retrieving an *object* from sqlite.
I know the general sql statements.
Thanks
______________________________________________________________________
This communication is from Primal Pictures Ltd., a company registered in
England and Wales with registration No. 02622298 and registered office: 4th
Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT
registration No. 648874577.
This e-mail is confidential and may be privileged. It may be read, copied and
used only by the intended recipient. If you have received it in error, please
contact the sender immediately by return e-mail or by telephoning +44(0)20 7637
1010. Please then delete the e-mail and do not disclose its contents to any
person.
This email has been scanned for Primal Pictures by the MessageLabs Email
Security System.
______________________________________________________________________<<winmail.dat>>

