Hi to all!
I read a record from a mySql table with mysql_fetch_object.
Is there a way to cast it to a particular class, for example, Student? Of course, I have defined a Student class.
Can I do it?
Thanks a lot,
Nicolas
Casting
Moderator: General Moderators
not sure if you can cast from one class to another. however you could possibly create a constructor that accepts an object and copy the field values like so.
or something similar
Code: Select all
class Student {
var $name;
var $grade;
function Student($obj) {
$this->name = $obj->name;
$this->grade = $obj->grade;
}
}