Jump to content

Objects and Assigning A Value Query


MoFish

Recommended Posts

Hi,

 

I have the following code which works well.

$this->data['results'] = $this->domain_status_model->get();
foreach($this->data['results'] as $result){
  $result->domainstatus_items = $this->domain_model->get_by_status($result->domainstatus_id);

I would like the ability to target my array a little more specifically. I therfore am trying to replace the domainstatus_item portion using a returned value from another query. When I try this, it does not appear to be working, probably due to a simple mistake. I have tried using . + and & operators in order for it to work, however am not having much success.

$this->data['results'] = $this->domain_status_model->get();
foreach($this->data['results'] as $result){
  $result->domainstatus_$result->domainstatus_title = $this->domain_model->get_by_status($result->domainstatus_id);

In summary, the value returned from $result->domainstatus_title is for example 'pending' and I am trying to get the following:

$result->domainstatus_pending = $this->domain_model->get_by_status($result->domainstatus_id);

Any help would be much appriciated. ::)

 

Kind regards,

 

MoFish

Link to comment
https://forums.phpfreaks.com/topic/294564-objects-and-assigning-a-value-query/
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.