簡體   English   中英

Codeigniter -> 簡單select全部查詢

[英]Codeigniter -> Simple select all query

我有我的 model:

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

我將如何返回我的$result以便我可以通過以下形式通過我的 controller 調用它?

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

您可能可以在 model 中創建一個 function getCompanyDetails($companyName) 。然后從您的 controller 調用此方法。 $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();
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM