CODEIGNITER ISSUE中的JOIN TABLES

时间:2018-03-09 08:30:30

标签: codeigniter-3

我有Fours表来加入。

Tables in DB

我的型号代码:

public function get_all_customers()
{

    $this->db->select('*, customerID, custstr, CONCAT(custstr, '.', customerID) AS custcode')->from('customers');

$this->db->join('deliverydays', 'customers.DeliveryDaysID = deliverydays.DeliveryDaysID', 'left');
$this->db->join('deliveryman', 'customers.DeliveryPersonID=deliveryman.DeliveryManID');
$this->db->join('reference', 'reference.referenceID=customers.referenceID');
$this->db->order_by('customerID','asc');         
$query = $this->db->get(); 

   return $query->result_array();
}

我的控制器代码:

$customers=$this->customer_model->get_all_customers(); 
$data ['customers'] = $customers;
$this->loadViews("customer_view", $this->global,  $data);

查看代码是:

<?php foreach($customers as $customer){?>
             <tr role="row" class="" >
                 <td class="sorting_1"><?php echo $customer->custcode;?></td>
                 <td><?php echo $customer->Name;?></td>
                <<td><?php echo $customer->dmName;?></td>
                 <td><?php echo $customer->referenceName;?></td>
    </tr><?php }?>

问题

问题在于它是错误的

消息:尝试获取非对象的属性

哪里有问题?我想不出来。

1 个答案:

答案 0 :(得分:1)

导致此问题的原因是您将模型中的数据作为数组格式return $query->result(); 返回,并在视图页中检索为对象。

因此,请按照以下代码更改模型返回

proc->start("cd /usr/local/bin/ && individual");

希望它会解决......