Codeigniter - >简单选择所有查询

时间:2012-04-07 01:36:30

标签: php codeigniter

我有我的模特:

$this->db->select('companyName,companySlogan,companyContact,companyEmail,companyWebsite,companyPhone,companyFax,companyAddress');
$result = $this->db->get('companyDetails');

如何退回$result以便我可以通过以下表格通过我的控制器进行调用?

$data['companyName'] = $this->quote->companyDetails->companyName

1 个答案:

答案 0 :(得分:1)

你可以在模型中创建一个函数getCompanyDetails($companyName)。然后从您的控制器调用此方法。 $this->quote->getCompanyDetails('abc');

如下所示。请注意,如果出现错误,请对此进行测试并进行微小更改。基本思路如下。

public function getCompanydetails($companyName)
{ 
$this->db->select('companyName,companySlogan,companyContact,companyEmail,companyWebsite,companyPhone,companyFax,companyAddress');
    $result = $this->db->get($companyName);
    return result->result_array();
}