How to print SQL statement in codeigniter model

前端 未结 14 1990
迷失自我
迷失自我 2020-11-30 22:08

I have a sql statement in my model,

I then say

$query = $this->db->query($sql, array(fields, fields1);

if ($query) {
    return true:
} else {         


        
14条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 22:41

    I had exactly the same problem and found the solution eventually. My query runs like:

    $result = mysqli_query($link,'SELECT * FROM clients WHERE ' . $sql_where . ' AND ' . $sql_where2 . ' ORDER BY acconame ASC ');
    

    In order to display the sql command, all I had to do was to create a variable ($resultstring) with the exact same content as my query and then echo it, like this:

    It works!

提交回复
热议问题