开发者

How to create a Data Access Object in Flex

开发者 https://www.devze.com 2023-03-30 03:24 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消