AV1611 Posted January 1, 2007 Share Posted January 1, 2007 I have a lot of tables that I update en mass via cron.I need to delete the table then parse in new data from text file. no problemPhilosophy question:I don't want to delete the old table until I'm sure that the new data is valid.Is the right method to parse the new data into an array then test the array then delete the old table then parse in the new data from that array, or is there a better way?Perhaps write to temp table first?this is a philosophy question Link to comment https://forums.phpfreaks.com/topic/32493-solved-table-update-philosophy/ Share on other sites More sharing options...
JasonLewis Posted January 1, 2007 Share Posted January 1, 2007 i would think it would depend on how your testing it, and also what you are more experienced with. i would probably use arrays because i find they are easier to deal with. :) Link to comment https://forums.phpfreaks.com/topic/32493-solved-table-update-philosophy/#findComment-150991 Share on other sites More sharing options...
corbin Posted January 1, 2007 Share Posted January 1, 2007 You could insert the data into table_new then verify the data by counting the rows or something and then drop table if its valid then rename table_new table. Link to comment https://forums.phpfreaks.com/topic/32493-solved-table-update-philosophy/#findComment-151014 Share on other sites More sharing options...
MCP Posted January 2, 2007 Share Posted January 2, 2007 From a DB theory point of view, I believe the preferred method would be roughly:-----start transactiondelete old tableinsert new rows into the tableif error then rollback transactionelse commit transaction----- Link to comment https://forums.phpfreaks.com/topic/32493-solved-table-update-philosophy/#findComment-151122 Share on other sites More sharing options...
corbin Posted January 2, 2007 Share Posted January 2, 2007 There has to be backup to do that htough which makes another step Link to comment https://forums.phpfreaks.com/topic/32493-solved-table-update-philosophy/#findComment-151125 Share on other sites More sharing options...
JasonLewis Posted January 2, 2007 Share Posted January 2, 2007 you wouldnt want to delete the old table straight off incase there is something wrong. i am starting to think that inserting the new table as a test name, checking it then if it is good delete the old table then rename the new table, which i think was mentioned. it just sounds easierish :) Link to comment https://forums.phpfreaks.com/topic/32493-solved-table-update-philosophy/#findComment-151130 Share on other sites More sharing options...
MCP Posted January 2, 2007 Share Posted January 2, 2007 [quote author=corbin link=topic=120607.msg494976#msg494976 date=1167700661]There has to be backup to do that htough which makes another step[/quote]backup? I don't think so... The database will handle everything without any sort of "backup". Whatever it does behind the scenes is not important -- there's no additional steps from a user point of view.ProjectFear -- what sort of tests are you performing on your data? Link to comment https://forums.phpfreaks.com/topic/32493-solved-table-update-philosophy/#findComment-151155 Share on other sites More sharing options...
AV1611 Posted January 2, 2007 Author Share Posted January 2, 2007 So, what I think I am hearing is this:Pull the new data to a temporary tableTest for appropriate rows in the tabledelete the contents of the old tableupdate the old table with the contents of the temporary tableThat seems safe to me...Agreed? Link to comment https://forums.phpfreaks.com/topic/32493-solved-table-update-philosophy/#findComment-151287 Share on other sites More sharing options...
JasonLewis Posted January 2, 2007 Share Posted January 2, 2007 yeh i'll agree on that. seems the best bet to me. Link to comment https://forums.phpfreaks.com/topic/32493-solved-table-update-philosophy/#findComment-151744 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.