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;