How to run a codeigniter application on offline mode

[eluser]Jack Taylor[/eluser]
Hi All,

I am using CI just for last one years, I develop several application on it. But now a days I think that how we can run an application on offline mode [internet not available]. I am thinking on it. Can someone suggest me that how a CI application on offline mode? How much I have to change on my existing application.


You mean with no connection to the server the application is running on?

[eluser]Jack Taylor[/eluser]

Yes, I mean to say that one copy of my CI application already running on my local system, on every request I will check the internet availability, if internet is available than every request will go to my online sever otherwise request will redirect to my local server and I will track every change in my database (insert, update, delete) and databases will syncronize later when internet connection is available.

I am using MySql database.


You already do that or you want to know how to achieve that behavior?

[eluser]Jack Taylor[/eluser]
Yes I am lot interested to know how to achieve that behavior.

I guess you would have to do quite some hacking:
1. The database class needs to be adjusted to switch connections depending on you being online/offline. Alternatively you could only change the config/database.php file and set the connection depending on your online/offline state.
if ([email protected]$fp = fsockopen("", 80, $errno, $errstr, 1)){
// set offline database connection
else {
// set online database connection
2. If the worst comes to the worst, you would have to come up with a solution for logging the changes yourself. I don't know if MySQL comes with a built-in solution for that, but CI doesn't.
3. As far as the synchronizing is concerned, you would have to turn the logged changes into insert/update/delete querys and run them on your online database. Again no built-in solution in CI.

@2 and 3:
This might help...haven't looked into it in detail but master/slave or master/master replication might be exactly what you need:

This might also lead to:

[Haven't tried it yet myself.]

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.