MySQL, PHP, Codeigniter, CSS and JQuery working tips.

Author: Zeeshan Rasool  |  Mar 13, 2010 Codeigniter, CSS, JQuery, SEO, Technology, Web Development

Following are some useful tips when a developer needs them while developing. Keeping these points in mind will help us to improve our skills.

Codeigniter

Codeigniter is PHP framework which is light weight and very easy to configure and a lot of help available online.
Use separate models for each module so that tracking can be easy.

Front and admin should be handled with separate controllers.
Use parser library for loading views.

In config folder routes file will help you to create pretty urls.

Define all your global constants in config/constant.php or create a separate file for this.

Use flash session for your messages to users.

Don’t call any model function inside views as it is not a valid in MVC.
If you want to keep your application folder outside system folder then you need to change path in index.php on main root.

Use rollback functions to keep track the functions otherwise revert all of your actions on failed.

Include all of you css and js files in views separately from controller.
Don’t include all CSS or JS files on single page i-e index.php

PHP

Use switch conditions instead of  if / else in case of using too much conditions. Switch condition is much faster than if / else.

For multiple conditions its best to use switch condition.

Keep all particular functionality like, code for uploading a file, getting date in specific format etc in separate functions so that you can re-use them instead f writing it again.

Use server side validation for required input fields with client side validation.

Single quotes is faster than double quotes for string or query in quotes.

Keep error reporting on, so that notices and warnings may be fixed. These small notices may produce some problems on your server online.
Comment your code, what you have done. So next time you are any other developer understand your code easily.
Use .htaccess to put some securities on your code.
Declare all variables properly so that they produce no problem in executions.

MYSQL

Get last 24 hours or 1 day records in mysql.

Export your table to CSV file.

Don’t use DISTINCT when you have or could use GROUP BY,
LIMIT m,n may not be as fast as it sounds.
Don’t use ORDER BY RAND() if you have > ~2K records
Avoid using IN(…) when selecting on indexed fields, It will kill the performance of SELECT query.
Minimize traffic by fetching only what you need.
1. Paging/chunked data retrieval to limit
2. Don’t use SELECT *
3. Be wary of lots of small quick queries if a longer query can be more efficient.
Do not duplicate indexes.
Avoid wildcards at the start of LIKE queries.

CSS

Keep css Simple.
Don’t use hacks unless its a known and documented bug.
Take care of margins and padding on all elements.
Avoid using too much absolute positioning.
Validate your code

JQuery

Disable right click.

Re-size font.

Equal height columns.

Remove a word in a text

Preloading images

Recommended WordPress Themes Stores



If you enjoyed this post, please consider leaving a comment below or subscribing to the RSS feed to have future articles delivered to your feed reader. You can also follow us on Facebook or Twitter @99Points

This awesome post has been created by 99Points editor's team. You can follow our updates on Twitter and facebook, OR drop an email at 99points.info@gmail.com



Email Subscriber!

Be the first to know about new updates


Author of 99Points
Zeeshan Rasool is an experienced PHP Web Developer and founder at 99Points. Expert in Codeigniter (MVC), WordPress, JSON, jQuery & HTML5
 LinkedIn Profile  About.me


Advertisement




Friends


Categories


Popular post