Need help for connect database at different

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
windforceus
Forum Newbie
Posts: 23
Joined: Tue Mar 15, 2005 12:40 pm

Need help for connect database at different

Post by windforceus »

Hi ALL

I have a php website connected to mysql database in win2000 and I plan to backup my database at 12pm every night. Users will be directed to the other database. My problem is what happen if someone log in to my website at that time? I don't know if there is such thing to disconnect user in php or reconnect a different database at certain time. If any knows...i appreciate.

ray
windforceus
Forum Newbie
Posts: 23
Joined: Tue Mar 15, 2005 12:40 pm

any help is appreciated

Post by windforceus »

I notice someone mention "crons" and "crons" seems can start a php script at certain time. Then, how about the users who are logging in already or have brower open?
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

...

Post by Calimero »

Can't you just do it in PHP - include() it:

take the time and if between START of backup and END of BACKUP time - you think you will need: just give other parameters for DB connection and login.
windforceus
Forum Newbie
Posts: 23
Joined: Tue Mar 15, 2005 12:40 pm

hmm...thanks for reply

Post by windforceus »

yes, i know i can include()..but that mean the website have to keep checking the time, right? So putting a time function in db.php and checking which db i will use will make the website be able to keep checking the time difference?
windforceus
Forum Newbie
Posts: 23
Joined: Tue Mar 15, 2005 12:40 pm

my concerns is...

Post by windforceus »

The include function work when the page is loaded, so what happen if people load the page at 12:01 and i start to back up the database at 12:00? I need to have precise way to do this...
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

why do you want to use another database server anyway? while the mysqldump is executing, concurrent changes to your data won't be included (they will be in the backup of tomorrow). even if you directd to a *different* server, the one you are using as a source for the backup doesn't know about those changes... in this case you're ready for real pita situations..



------------------------------------------------------------------------------------
on a big site, i always see the following structure:

(these are the replications that are used for read/select)
[repl1] [repl-2] ..... [repl-n]

(this is the one used for write/insert/update)
[master]
windforceus
Forum Newbie
Posts: 23
Joined: Tue Mar 15, 2005 12:40 pm

thanks for reply

Post by windforceus »

Sorry, i am a newbie...that is why i may ask dump question. What is mydqldump doing in the database? i saw it in mysql but i dont' know what it is for..So concurrent change wont' be include? Say if those concurrent change is in the backup of tomorrow, i need to add the backup to my current database tomorrow? I have no exp on those process, that is why i ask those questions, hope you don't mind...
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

time to read the manual then, it's all explained in there... (comes down to run mysqldump every 24hours and you're set)
User avatar
phpScott
DevNet Resident
Posts: 1206
Joined: Wed Oct 09, 2002 6:51 pm
Location: Keele, U.K.

Post by phpScott »

mysql_dump just dumps all the data and other parameters you can set into a file and you can use that file to back up your db or what ever you want to do with it.

All that will happen is that any changes that occur while you are 'dumping' the database will be inserted into your back up the following day. Nothing to worry about as that is standard when doing back up's.

It is like changing your php script and then coping it some where else then going back to the original to make any changes, those changes won't be in your back up script until you copy over it agian.

phpscott
Post Reply