Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 979713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:15:42+00:00 2026-05-16T04:15:42+00:00

I want to make a program that pulls objects from a sql database and

  • 0

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:

  1. User specifies a date range in a javascript form.
  2. The date range is sent to a php file on the server that converts it to
    a sql query.
  3. 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).
  4. 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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:15:43+00:00Added an answer on May 16, 2026 at 4:15 am

    Your class definition should define the properties of the object, not the values. It should be defined statically, not dynamically at runtime. At runtime you create instances of this class and populate the data for each instance.

    Try something like this:

    class Food {
       var $name;
       var $temp;
       var $texture;
    
       // Constructor
       public function food($name, $temp, $texture) {
          $this->name = $name;
          $this->temp = $temp;
          $this->texture = $texture;
       }
    
       public function breaksDentures() {
          if($this->temp >= 15) && ($this->texture === 'hard')
             return true;
          else
             return false;
       }
    }
    

    And use it like this:

    function processFoods($daterange) {
       $query = build_query_from_daterange($daterange);
       $result = mysql_query($query);
    
       while($row = mysql_fetch_assoc($result)) {
          $food = new Food($row['name'], $row['temp'], $row['texture']);
          // Now $food is an instance of the Food class populate with the values
          // from the db, e.g., 'ice cream', 0, 'hard'.
    
          if $food->breaksDentures() {
             print("Don't eat it");
          }
       }
    }
    

    P.S. You may want to brush up on your object-oriented concepts. Your question is a good one but indicates some confusion about OO basics.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a program in Python that can take video input from
I want to make a program that will communicate with a database that has
i want to make a program that can extract the data from a removable
I want to make the program that downloads page from internet and makes some
I want to make a program that will simulate a user browsing a site
I want to make a program that will read some number in string format
I want to make a simple program that sends random keystrokes to my other
Basically I want to make simple toggle program (that will be mapped to some
I want to make a script that starts a program and then sends it
I want to make program that encrypts (later decrypts) user inputted string. Here is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.