Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
218 views
in Technique[技术] by (71.8m points)

php - download values of sql table for offline reuse

I've got a Flash app that calls an online php file in order to read some values of my SQL table.

So I've got a line like this in my AS3 code:

var urlReq:URLRequest = new URLRequest ("http://www.****.com/sql_result.php");

And this in my php :

 $connection = mysql_connect("mysql***.perso", "test", "password") or die ("Couldn't connect to the server.");

Problem : if the user is offline he can't access the values.

Is there way to download the SQL table with AS3 code (when the user have internet) in order to access it offline.

Like :

function onConnection(e:Event = null):void{
if(monitor.available)
            {
                trace("You are connected to the internet");
                read_php_online();
            }
            else
            {
                trace("You are not connected to the internet");
                read_php_offline();
            }

            monitor.stop();
        }

function read_php_offline():void{
    var urlReq:URLRequest = new URLRequest ("local/sql_result_offline.php");
..
..
}

And what should have sql_result_offline.php in order to access an offline SQL Table ?

 $connection = mysql_connect("LOCAL", "user", "password");

Thank you,

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

you have a flash swf, mobile app or air app?

Storing local data

you can use file as database (like csv), for mobile and air you can use local SQLite database.

if you have native desktop app - it is possible to use mysql, via native process or native extension but it is not so easy..

  • edit:
    Working with local SQL databases in AIR
    [+] you can keep your data safe- with encryption, a password at startup and etc.
    [-] it will require a lot more of code
    (create database after install, sync regularly, get data from local database if no internet conn.) mysql and sqlite have some differences also (like "insert or update" statement for sqlite)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...