Okay, so I have some functions that contain a huge SQL command to input data into a database. Problem is that I can't really find an elegant way to call all of them. Here's my current setup:
The functions sectionXinsert() basically returns a string with my SQL commands, which then gets executed. I won't list them here, because they are really, really, long. Really long.
The $results just act as my debugging, so that if something goes wrong it'll output the error messages.
I mean, I guess the easiest thing to do would be to create an array with all of the functions stored inside it, then just iterate through it, calling each function.
Any suggestions from anyone more knowledgeable, or who had a similar situation?
EDIT:
Just thinking as I go along, maybe just having a master function such as DoAllQueries where all of the functions get called would be a step in the right direction. But I mean, all I'm doing is shuffling deck chairs around, I'm still going to have some code where I just list all those functions to do.
Code:
//run the queries
$result1 = @mysql_query(section1insert());
$result2 = @mysql_query(section2insert());
$result3 = @mysql_query(section3insert());
$result4 = @mysql_query(section4insert());
$result5 = @mysql_query(section5insert());
$result6 = @mysql_query(section6insert());
$result7 = @mysql_query(section7insert());
$result8 = @mysql_query(section8insert());
$result9 = @mysql_query(section9insert());
$result12= @mysql_query(section12insert());
The functions sectionXinsert() basically returns a string with my SQL commands, which then gets executed. I won't list them here, because they are really, really, long. Really long.
The $results just act as my debugging, so that if something goes wrong it'll output the error messages.
I mean, I guess the easiest thing to do would be to create an array with all of the functions stored inside it, then just iterate through it, calling each function.
Any suggestions from anyone more knowledgeable, or who had a similar situation?
EDIT:
Just thinking as I go along, maybe just having a master function such as DoAllQueries where all of the functions get called would be a step in the right direction. But I mean, all I'm doing is shuffling deck chairs around, I'm still going to have some code where I just list all those functions to do.