How to run a codeigniter application on offline mode

#1
[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.

Thanks
Jack

#2
[eluser]davidbehler[/eluser]
You mean with no connection to the server the application is running on?

#3
[eluser]Jack Taylor[/eluser]
Hi,

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.

Thanks
Jack

#4
[eluser]davidbehler[/eluser]
You already do that or you want to know how to achieve that behavior?

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

#6
[eluser]davidbehler[/eluser]
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.
Code:
if (!@$fp = fsockopen("http://www.google.com", 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: http://www.howtoforge.com/mysql_master_m...eplication

#7
[eluser]wabu[/eluser]
This might also lead to: http://ellislab.com/forums/viewthread/125328/

[Haven't tried it yet myself.]


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


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