0

我有以下 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'

如何使用 codeigniters 活动记录来做到这一点?

4

2 回答 2

3

一种可能性是:

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

另请参阅CodeIgniter 用户指南,搜索$this->db->where();并查看Custom key/value method,有以下示例:

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

ps:还有两种选择:关联数组方法自定义字符串

于 2012-07-13T06:55:51.773 回答
1

您可以使用 : $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;
}
于 2012-07-13T06:51:36.117 回答