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!
}
}
たとえば、これで、たとえば;$name = pulic $wherever;
を呼び出すことができます。wherever->wherever
変数を追加するたびにこの名前を入力する必要がないように
public $md5;
public $credit;
public $pontaria_time;
public $Credits;
public $airoplayne;
public $city_id;
public $prisao_time;
public $crime2;
public $banck_time;