Welcome Guest, Not a member yet? Register   Sign In
showing how many queries are running on the page
#1

[eluser]A.M.F[/eluser]
hello,

i am a newbie to CI. i started a phew days ago and i got to tell u- this framework is awesome!

anyway...
i want to see how many queries i am running on my page because technical reasons. how can i do it with CI?
i need to edit the DB library and setup in there a variable that counts every query or there is a simple way to do it?

thank u!
#2

[eluser]Michael Wales[/eluser]
For debug purposes:
Code:
$this->output->enable_profiler(TRUE);

For a "cool" number of queries display at the bottom of your pages you can "show off" to users:
Extend the CI_DB_Driver class and rewrite the query() function, incrementing a class variable. In your controller, assign this class variable to a local variable and pass that to your view. Echo that local variable out in your view.
#3

[eluser]Neovive[/eluser]
Welcome to CI. Just add $this->output->enable_profiler(TRUE); to your controller and all the queries will be displayed along with additional performance information.
#4

[eluser]A.M.F[/eluser]
thank u guys! it was helpfull.
are there any more common things like this that i should know?
#5

[eluser]Michael Wales[/eluser]
The user is guide is located at http://www.ellislab.com/codeigniter/user-guide/? Big Grin

Here are a few quick tips off the top of my head:
1. If you use CI's Native Sessions (I love them, personally) - use the library available via the SVN.
2. You can get the SVN URL from the Download area in the User Guide.
3. Don't get stuck on only using CI code. There are tons of great third-party libraries and modifications that will make your life easier.
4. Validation is a great area for third-party libraries. Search these forums for SetFields() and validators - should save you a lot of time.
5. Always, always, always validate your input (beyond the validator class). Never trust your form submissions and never use a hidden field for anything you intend to verify.
6. <pre>&lt;?= print_r($this->data); ?&gt;</pre> is a life-saver
7. Never use Scaffolding
8. Use RegEx for URI Routing - the selectors CI provides will just make your life miserable
#6

[eluser]iive[/eluser]
Great Tips walesmd! Appreaciated it!!
#7

[eluser]A.M.F[/eluser]
walesmd thank u very much!

i am also using the YATS library as a template, and it's very helpful.

here are some quick questions-
1. why not to use Scaffolding ?
2. what is RegEx and URI Routing?

cheers!
#8

[eluser]Michael Wales[/eluser]
1. Scaffolding is highly insecure. What I mean by don't use it is - don't ever put it up on a live site or use it as part of your administration. Scaffolding is only good for filling your tables with dummy text while you develop your site and testing purposes. If you use Scaffolding on a live site, please provide your URL so I can hijack admin.

2. Regex are regular expressions - basically a way to compare a string to another. Google the term, there are thousands of tutorials out there. URI Routing is being able to say to CI "When you see domain.com/walesmd don't try to go to a controller named 'walesmd' go to 'users/profile/walesmd' instead." There are tons of other uses for it but that is one of the most common we get questions about. Check out the user guide.




Theme © iAndrew 2016 - Forum software by © MyBB