我有以下代码点火器模型函数:
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;
}