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

  • SEARCH
  • Home
  • 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 8472401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:03:47+00:00 2026-06-10T17:03:47+00:00

I have been following a very interesting tutorial that really tested my ability to

  • 0

I have been following a very interesting tutorial that really tested my ability to program Php. I always thought that I am the man but I turn out to be the worse of the worse. Having said that, during the tutorial a requirement to instantiate an object was explained so I typed this code down and do not get me wrong everything works fine no problem at all. The major thing is that I do not really understand how thing work underneath that is why I would like some one to explain to me even more.
my question when you pull a record from the data base using MySQL_fetch_array what and how is the data presented to the receiving variable. for example bellow

private static function instantiate($record){
 $object = new self;
   foreach($record as $attribute => $value){
     if($object->has_attribute($attribute)){
      $object->$attribute =$value;
     }
   }
   return $object;
 }

if I have 3 fields in a table e.g Name, age, address and a value let say Jhone, 23, arizona what will be store in the attribute and what will be store in the Key and where is the index and how do foreeach extract such data from the database like the example above and assign it to the other array. please I do not need any codes my codes are working fine, what I need is a very primitive and clear explanation. and indeed thank you in advance for your support.

  • 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-06-10T17:03:49+00:00Added an answer on June 10, 2026 at 5:03 pm

    What really helps is to print out stuff in your methods (with print_r for instance). For example, try this with your method:

    private static function instantiate($record){
     print_r($record);
     $object = new self;
     print_r($object);
       foreach($record as $attribute => $value){
         echo "attribute: $attribute, value:$value <br />";
         if($object->has_attribute($attribute)){
          $object->$attribute =$value;
         }
       }
       print_r($object);
       die();
       return $object;
     }
    

    That way, you can see exactly what is going on with the object, foreach etc.

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

Sidebar

Related Questions

I am very new to PHP, so far I have been using the following
I am very new to programming, and have been following a C++ tutorial for
I have been following the affableBean tutorial from the NetBeans site located here .
I have been following a tutorial on how to write a basic tile map
I have been following the tutorial on Microsofts website and they use GameTime to
I have been following a short tutorial to build a tab menu on my
I am new to Ajax and have been following a tutorial from JQuery.com. I
I have been following along with the book Practical Django Projects. Very nice book,
I'm new to jQuery and have been following the tutorial here for a Panel
I'm very new to Ruby on Rails, and have been getting the following error

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.