Jump to content

Instantiate


designanddev

Recommended Posts

im using this code here to instantiate all my records from the data, but i am having trouble trying to use the join another table cell to this

 

 

 

private function instantiate($record){

$object = new self;
//$object->username   = $record['username'];
//$object->password   = $record['password'];
//$object->first_name = $record['first_name'];
//$object->last_name  = $record['last_name'];

foreach($record as $attribute => $value){
if($object->has_attribute($attribute)){
$object->$attribute = $value;
}
}
return $object;
}

Link to comment
https://forums.phpfreaks.com/topic/272502-instantiate/
Share on other sites

Private Function can only be used and called to inside the class it is defined in (if I'm right) which means that when you call new self it runs a endless loop.

 

I tried running something similar to test that this was right and it returned this:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65488 bytes)

Link to comment
https://forums.phpfreaks.com/topic/272502-instantiate/#findComment-1402111
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.