CodeIgniter Forums
Generated SQL query in 4 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: Generated SQL query in 4 (/thread-76852.html)



Generated SQL query in 4 - stepgr - 06-27-2020

Hi all,

very new to CI and after a short time in v3 I started to getting familiar with v4 . I have some ready sql queries
(from phpmyadmin) that I would like to put into  a model . I have trouble when I have sub-queries
and I wonder if there is a way to view the generated query before it executes ?


RE: Generated SQL query in 4 - dave friend - 06-27-2020

(06-27-2020, 03:17 AM)stepgr Wrote: Hi all,

very new to CI and after a short time in v3 I started to getting familiar with v4 . I have some ready sql queries
(from phpmyadmin) that I would like to put into  a model . I have trouble when I have sub-queries
and I wonder if there is a way to view the generated query before it executes ?

The builder class has four methods to get the generated query - one each for select, insert, update, and delete. Here are the signatures for them. They all return a string.

getCompiledSelect([$reset = TRUE])
getCompiledInsert([$reset = TRUE])
getCompiledUpdate([$reset = TRUE])
getCompiledDelete([$reset = TRUE])

As you've probably realized, $reset is a bool used to indicate whether to reset the current QB values or not.


RE: Generated SQL query in 4 - stepgr - 06-27-2020

Thanks , very helpful .