繁体   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