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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.