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 7961541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:04:06+00:00 2026-06-04T05:04:06+00:00

class User extends DatabaseObject { protected static $table_name=’users’; protected static $db_fields = array(); public

  • 0
class User extends DatabaseObject {

    protected static $table_name='users';
    protected static $db_fields = array();

public  function __construct() {

    // Get columns from table
    global $database;
    $result_set = $database->query("SELECT * FROM ".self::$table_name." LIMIT 1");
    $num_fields = mysql_num_fields($result_set);
    for($i=0; $i<$num_fields; $i++) {
        $column_name = mysql_field_name($result_set, $i);
        // Set column names as variables
        self::$db_fields[] = $column_name; // THIS WORKS
    $this->{$column_name}; // THIS IS PROBLEMATIC!

  }

}

for example this $name = pulic $wherever;
so I can call, for example, wherever->wherever;

so that I don’t have to type this name every time I add the variables

public $md5;
public $credit;
public $pontaria_time;
public $Credits;
public $airoplayne;
public $city_id;
public $prisao_time;
public $crime2;
public $banck_time;
  • 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-04T05:04:08+00:00Added an answer on June 4, 2026 at 5:04 am
     $this->{$column_name}; // THIS IS PROBLEMATIC!
    

    You need to use

    $this->$column_name = $column_value
    

    OR you can write all columns in $db_fields field and add

    public function __get($name) {}
    

    (read about magic methods)

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

Sidebar

Related Questions

I implemented Service for listening user location: public class ListenLocationService extends Service { private
I implemented Android service for listening user location: public class ListenLocationService extends Service {
Here's my use case : public class User extends Model {} public class TableA
So i use CakePHP 2.0.5 . My model: class User extends AppModel { public
I created a user model in Code Igniter. class User extends CI_Model { function
my child class is public class User extends Alien { public User(XYCoordination currentLocation, int
I've got a zend framework model: class User extends Zend_Db_Table_Abstract { protected $_name =
As per here I've got the following controller: class User extends CI_Controller { public
This is my User class public class User extends Model { @Id public Long
This is my parent class: class Model extends CI_Model { protected $table, $idField='id'; public

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.