簡體   English   中英

笨。 如何返回變量值大於數據庫中字段的記錄?

[英]Codeigniter. How to return records where value of variable is more than field in database?

我有以下codeigniter模型函數:

function get_successful($project_id, $amount_backed){
    $data = '';

    $this->db->where('id', $project_id); 
    $this->db->where($amount_backed >= 'funding_goal'); //HELP HERE
    $this->db->where('published', '1'); 

......

    return $data;
}

我只需要獲取變量$amount_backed或等於字段'funding_goal'

如何使用代碼點火器活動記錄來完成此操作?

一種可能性是:

$this->db->where('funding_goal <=', $amount_backed);

另請參見《 CodeIgniter用戶指南》 ,搜索$this->db->where(); 並查看Custom key/value method ,有以下示例:

$ this-> db-> where('id <',$ id);

附言:還有兩個選擇: 關聯數組方法自定義字符串

您可以使用: $this->db->where("funding_goal < $amount_backed")

a < b == b>=a

function get_successful($project_id, $amount_backed){
    $data = '';

    $this->db->where('id', $project_id); 
    $this->db->where("funding_goal < $amount_backed"); //HELP HERE
    $this->db->where('published', '1'); 

......

    return $data;
}

暫無
暫無

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

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