How to create a Data Access Object in Flex
I read that when working with SQLite local database in Flex (no other framework) it is considered best practice to have a singleton data access object class.
While the singleton part is clear, I am not sure what the DAO part would mean in a Flex app.
So, how do you create a data access object in Flex (for SQLite transactions)?
EDIT:
What I currently do is somethi开发者_Python百科ng like this:public class Database
{
//constructor, instantiation of sqlConnection and others
//...
public function getPeople():Array
{
var query:SQLStatement=new SQLStatement();
query.sqlConnection=sqlConnection;//Defined in the constructor as static
query.text='select * from people order by name asc';
try
{
query.execute();
return query.getResult().data;
}
catch(e:SQLError){}
return null;
}
}
Thank you.
精彩评论