[英]Codeigniter -> Simple select all query
I have my my model:我有我的 model:
$this->db->select('companyName,companySlogan,companyContact,companyEmail,companyWebsite,companyPhone,companyFax,companyAddress');
$result = $this->db->get('companyDetails');
How would I return my $result
so that I can call it via my controller in the following form?我将如何返回我的
$result
以便我可以通过以下形式通过我的 controller 调用它?
$data['companyName'] = $this->quote->companyDetails->companyName
you can probably create a function getCompanyDetails($companyName)
in model. Then call this method from your controller. $this->quote->getCompanyDetails('abc');
您可能可以在 model 中创建一个 function
getCompanyDetails($companyName)
。然后从您的 controller 调用此方法。 $this->quote->getCompanyDetails('abc');
Something like below.像下面这样的东西。 Note, please test this and do minor changes if there is an error.
请注意,请对此进行测试,如果有错误,请进行小的更改。 The basic idea is given below.
基本思想如下。
public function getCompanydetails($companyName)
{
$this->db->select('companyName,companySlogan,companyContact,companyEmail,companyWebsite,companyPhone,companyFax,companyAddress');
$result = $this->db->get($companyName);
return result->result_array();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.