On Feb 18, 2011, at 18:20, cricket wrote: > On Fri, Feb 18, 2011 at 4:05 PM, Ryan Schmidt wrote: >> > >> On Feb 18, 2011, at 06:10, Djonatan Buss wrote: >> >>> I have been having the help of a friend that works with a cake but I >>> couldn't find the right way to see the SQL generated by cake. >>> >>> In order to learn it better and understand how it makes SQL and why theres >>> some troubles sometimes. >>> >>> So I would like to know how do I check every INSERT, UPDATE and SELECTs >>> that cake does. >>> which method do I have to use, where it should be placed and thing like that >>> >>> I'm using the cake default layout in order to check the SELECTS but I would >>> like to see the other as well... >> >> The default CakePHP SQL debugging will only show you the queries that >> happened on this request. I too wanted to be able to see queries that >> happened on other previous related requests -- for example, if you submit a >> form that adds, edits, updates or deletes, then it will do those things, and >> then redirect to another page which then displays the new data; CakePHP's >> default only shows the queries to select the new data and not the queries to >> actually change the data. >> >> One solution is to use the debugkit: >> >> https://github.com/cakephp/debug_kit#readme >> >> It adds a toolbar to your page where you can view the queries for each >> individual page. It also has other features that may be interesting to you. > > You should check out the new Cake logging features: > http://book.cakephp.org/view/1561/Migrating-from-CakePHP-1-2-to-1-3#!/view/1194/Logging > > This is exactly something I've been meaning to look into, actually. > I'm pretty sure, based on my own cursory examination, that this is > what you should be looking at. I'd like to hear back from anyone who's > already done something with this.
So you're suggesting the queries should be logged to a file? That's certainly an option, but I prefer being able to see them directly in the web page. The default CakePHP query display does this, but only for queries that happened on that request. To see queries that happened on previous related requests, the debugkit can be used, but I find it inconvenient to have to click a button in the bar at the top and than click through each separate request to see what happened, every time I want to see it. In a previous non-CakePHP project I worked on, we showed all queries since the last request at the bottom of the page in a debug area. Queries were simply stored in the session, and cleared out of the session when displayed. This area could be shown or hidden, and this was remembered between pages too (using a flag in the session). This worked well for us. I have yet to investigate how to build this with CakePHP but it shouldn't be too hard to do, if I spend some time looking at how debugkit was written. -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
