开发者

Less painful way to migrate from MySQL to a local single file implementation of the database (flash & AS3)

i have a database in MySQL who i query from a php script. Now i want to run the same aplication but in local (without the php script, the mysql and whitout the server). I develop the IDE of the new app using flash (AS3), now the th开发者_开发百科ink is that i need to migrate the data base too.

I was thinking using SQLite wich is great because it use the same commands that mysql and is local, but i really dont know how to make querys from AS3 to sqlite whitout using php. I was also thinking to develop a simple script who read my actual data base (mysql) and parse all the data to a new XML file who then i can read from the new IDE develop in flash, the problem is, that in this way i have to write all the code for the querys, i mean, when i use php+mysql and i need all the data WHERE reef=2 i just make a simple query, but with the new hypothetical schema flash+xml to make a simple query like that i have to write a lot of code if you know what i mean.

So, if you have any ideas let me know, remember that im developing in AS3 with FLASH. Thanks!


adobe air is the only way you can achive this on a local computer.

here some snippets:

// connect to SQLite
var file:File = preferences.resolvePath("data.db");
var sqlConnection:SQLConnection = new SQLConnection();
sqlConnection.open(file);

// prepare statement to find photos in album
var stmtFindPhotosToAlbum:SQLStatement = new SQLStatement();
stmtFindPhotosToAlbum.sqlConnection = sqlConnection;
stmtFindPhotosToAlbum.text = "SELECT * FROM photos WHERE album_id = :album_id";

// execute query
stmtFindPhotosToAlbum.parameters[":album_id"] = 'albumId';
stmtFindPhotosToAlbum.execute();

// get result
var photos:Array = stmtFindPhotosToAlbum.getResult().data;
var photoVos:Array = [];
if (photos != null && photos.length > 0)
{
  for(var i:int = 0;i<photos.length;i++)
  {
    // ...
  }
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜