How to print SQL statement in codeigniter model

前端 未结 14 1804
迷失自我
迷失自我 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:55

    You can simply use this at the end..

    echo $this->db->last_query();
    
    0 讨论(0)
  • 2020-11-30 22:58

    I'm using xdebug for watch this values in VSCode with the respective extension and CI v2.x. I add the expresion $this->db->last_query() in the watch section, and I add xdebugSettings node like these lines for get non truncate value in the launch.json.

    {
      "name": "Launch currently open script",
      "type": "php",
      "request": "launch",
      "program": "${file}",
      "cwd": "${fileDirname}",
      "port": 9000,
      "xdebugSettings": {
        "max_data": -1,
        "max_children": -1
      }
    },
    

    And run my debuger with the breakpoint and finally just select my expresion and do click right > copy value.

    0 讨论(0)
提交回复
热议问题