Serialize object from within
- by Maximus
I have the class testClass which has the method save. This method saves object to a database. But it needs to serialize object before saving. How can I serialize object from within the class to do that?
class testClass {
private $prop = 777;
public function save() {
$serializedObject = serialize(self);
DB::insert('objects', array('id', 'object'))
->values(array(1, $serializedObject))
->execute();
}
}
serialize(self) obviously doesn't work.