CodeIgniter Forums
Pre-query / OnConnect-query - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: Pre-query / OnConnect-query (/showthread.php?tid=82139)



Pre-query / OnConnect-query - nowackipawel - 06-16-2022

Hi there,
I do not have idea how I could achieve some kina of ON-CONNECT QUERY connection in the best way.
Let's say when CI is connecting to database I would like to send one query (i.e. set time_zone = "+00:00") I do not have any other option to do so on specific machine.
I do not want to repeat that query many times, just once when the connection is initialized(). I was thinking about some otpions like extending some classes of CI or add a support for that in Config file and CI itself and do the PR to the CI repo .... but the question is: Is there no option actually in CI to do so? I cannot find anything in the docs.


RE: Pre-query / OnConnect-query - nowackipawel - 06-18-2022

So it looks the best is to do the query every time I know I will be asking DB using i.e. : db_connect->simpleQuery('SET time_zone="+00:00"); I cannot believe there is no better way to do this. Sad