Weird backticks behaviour in Active Record in CodeIgniter 2.0.3

后端 未结 9 1593
迷失自我
迷失自我 2020-12-29 06:08

Previously my all queries were running fine in CI version 2.0 but when I upgraded to 2.0.3 some of my SELECT queries were broken.

CI is adding

9条回答
  •  一整个雨季
    2020-12-29 06:27

    CI will only protect your ACTIVE RECORD calls, so if you are running $this->db->query(); you will be fine, and based on the notes you should be safe with AD calls like so to disable backticks (not sure why you say they don't work, but I don't see your full code, so I can't be sure)

    $this->db->select('(SELECT SUM(payments.amount) FROM payments WHERE payments.invoice_id=4') AS amount_paid', FALSE);
    $query = $this->db->get('mytable');
    

    make sure FALSE is without single quotes (makes it a string), and it might not validate (not tested by me).

提交回复
热议问题