tracy Posted December 4, 2006 Share Posted December 4, 2006 If I have several databases, each with their own website. I need to have one main website database with all these individual database records duplicated in it...what is the best way to do that? I will need to change the data in the individual databases at the store level daily and have the changes update both on the individual sites and the main website with all the smaller sites 'feeding' to it somehow...For info, if an item is selected in the main large database, the browser will be linked back to the individual website from which that data came...thanks.I'm interested in the method here so that I will know how to approach the php script to make this all happen. Thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/ Share on other sites More sharing options...
Hypnos Posted December 4, 2006 Share Posted December 4, 2006 You could setup a cron job to backup the databases to a sql file, then FTP it to your main server. Your main server then just needs a cron job that takes place about 20 minutes later, that truncates the tables and then reads the sql files.Or, if this isn't private data, you could have each site generate a sql or csv file and post it on the respective webserver with a cron job. Then have your main site fetch all the files. Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/#findComment-134918 Share on other sites More sharing options...
tracy Posted December 4, 2006 Author Share Posted December 4, 2006 that sounds about like what I want to do...I just don't know much about cron jobs. it's not private data, it's publicly for sale inventory. However, there are security issues for the servers, like preventing injection problems, viruses, etc...Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/#findComment-134919 Share on other sites More sharing options...
keeB Posted December 4, 2006 Share Posted December 4, 2006 Uhm......[code] <?php mysql_connect("someIPaddress", "user", "password");?>[/code]What's keeping you from feeding the database directly? Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/#findComment-134933 Share on other sites More sharing options...
HuggieBear Posted December 4, 2006 Share Posted December 4, 2006 I'd suggest going the other way. Have one database (the big one you mentioned) with all the data in it. Then have all the websites only select the content they need for their individual site.It's a lot easier to do it this way than in reverse the way you're doing it, and it means only one database to maintain.The disadvantage is may have to modify your database structure a little, carry out some normalisation on it to make it a feasible solution.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/#findComment-134939 Share on other sites More sharing options...
tracy Posted December 4, 2006 Author Share Posted December 4, 2006 I'm concerned about security.I don't want each site to have that kind of access to the main site with all the data in it.The way I suggest, if one individual database or website administrator messes up, then only one small site is affected. The other small databases are still feeding the main ad site.I don't mind the extra work. I hope to get php to handle most of that for me anyway... Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/#findComment-134941 Share on other sites More sharing options...
keeB Posted December 4, 2006 Share Posted December 4, 2006 But, conversely, you don't have truely updated integration, so there's no real point of pushing this data to the 'master' database, from what I can tell. What you are suggesting does not make too much sense. Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/#findComment-134945 Share on other sites More sharing options...
tracy Posted December 4, 2006 Author Share Posted December 4, 2006 Let's say five boat dealers have each a website. Each has a database. Say I maintain one master database with their inventory altogether hosted on it and advertise that website with the main database. Each dealer could log on to his site and update inventory daily. At the end of the day, I'd like the main website updated automatically to update the main website data. That way, if a browser stopped by the main website and wanted to see inventory from all five dealers, he could and the data would be fresh and accurate through that day...I would not want each dealer to be logging into the main site database for obvious reasons. Say an employee of one dealer got mad and took down the site? Say there was some error by a dealer and he deleted his database. I know it might be rare, but these things happen. I'd much rather each dealer be dealing with his own database only than the main database. Does that make any sense? That's my take on it. Now, how do I make that happen? What method is best for the main database site to get its updates? Is it cron jobs? Is it a repetitive php file from the main site? Is it a daily repetitive file from each small site? What's the best way? opinions are appreciated. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/#findComment-134950 Share on other sites More sharing options...
keeB Posted December 4, 2006 Share Posted December 4, 2006 Tracy:This is where Database permissions come in handy. Only allow them insert and select statements on their respective accounts, and not delete / drop / create etc etc. Also, only allow them to use a certain table, or set of tables in such database.If you need help in setting ti up properly, don't hesitate to ask. - Keeb Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/#findComment-134951 Share on other sites More sharing options...
HuggieBear Posted December 4, 2006 Share Posted December 4, 2006 [quote author=tracy link=topic=117288.msg478546#msg478546 date=1165252878]I would not want each dealer to be logging into the main site database for obvious reasons. Say an employee of one dealer got mad and took down the site? Say there was some error by a dealer and he deleted his database. I know it might be rare, but these things happen. [/quote]This indicates poor coding and database design, with the correct permissions for database users and well designed queries in the php, you can prevent this from happening.RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/#findComment-134952 Share on other sites More sharing options...
tracy Posted December 4, 2006 Author Share Posted December 4, 2006 [quote author=keeB link=topic=117288.msg478547#msg478547 date=1165253235]Tracy:This is where Database permissions come in handy. Only allow them insert and select statements on their respective accounts, and not delete / drop / create etc etc. Also, only allow them to use a certain table, or set of tables in such database.If you need help in setting ti up properly, don't hesitate to ask. - Keeb[/quote]So the users could add/edit/delete their own stuff, not others...?...And you think this would be just as safe as having the main site draw from the other sites' db?I could 'secure it like crazy' to prevent it going down on a whim?... Quote Link to comment https://forums.phpfreaks.com/topic/29389-feed-database-info-to-multiple-sites/#findComment-134960 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.