I want to make a program that pulls objects from a sql database and processes the objects against a set of functions before returning the data to the user.
It will work like this:
- User specifies a date range in a javascript form.
- The date range is sent to a php file on the server that converts it to a sql query.
- The sql query pulls all data in the database that matches the date range, and stores each matching item and its associated information as a php class in a temporary php file (see example below).
- The main php program then processes each class in the temporary php file against a set of functions and returns the information to the user.
Example temporary php file:
class ice_cream
{
$temperature = 0;
$texture = 'soft';
}
class hard_candy
{
$temperature = 20;
texture = 'hard';
}
Example of Functions to process the classes against:
function will_it_break_dentures($class_name)
{
//$class_name is passed to the function based on the classes available in temp file
$food_type_class = new $class_name();
$damage_potential_temperature = $food_type_class->temperature;
$damage_potential_temperature = $food_type_class->texture;
if($damage_potential_temperature >= 15) && ($damage_potential_texture === 'hard')
{
print("Don't eat it");
}
}
Is there a more efficient/secure way to pull data from a database and process it against a set of functions? Is this the standard way to pull data from a database for processing? Item #3 seems suspect, but it's the best I could come up with. Any relevant informational resources on best practice are appreciated.