Mar
26
Error handling in cakephp

Error handling in CakePHP is pretty simple and straight forward. While developing in CakePHP with debug value set to > 0 (Configure::write(‘debug’, 1); in app/config/core.php) you might have encountered error messages something similar to this: Click to continue »

Tags : , , , ,

Mar
22
How to use multiple validation rule sets per model in cakephp

As default we have single var $validate rule set in the model class which is triggered on each save() method call while saving form data. This is quite logical and sufficient for single form fields to validate but what if we have another form with somewhat different fields which we want to post and validate? As an answer i know of three different approaches. Click to continue »

Tags : , , , , ,

Mar
21
How to apply search filters in cakephp ajax pagination

Sometimes we need to filter records via custom query while using ajax pagination in a cakephp application. An easy way to achieve this is to store query in a session varibale and to check it whenever an ajax call is made through “previous”, “next” or pagination links like 1,2,3 etc. Click to continue »

Tags : , , , , ,

Mar
21
Cakephp important facts you must know – Part 1

Mininal use of $uses variable to load models
CakePHP loads all models specified in var $uses array when a controller action is called. By loading a model cakephp creates the schema/structure of the table and also caches it for further use in the application.

Let say you specify four models in the var $uses. Now every time you call a controller action, all four models will be loaded irrespective of any of four being used by controller action or not. For example, Click to continue »

Tags : , ,

Mar
20
Multiple validation rules for a single field in cakephp

Cakephp framework provides a strong model validation mechanism. Here is the quick overview of multiple validation rules applied to a single field.

Let say we are using “User.password” and “User.password2″ fields to accept/confirm password while registering to a site. We have “password2″ field which is supposed to contain non-empty characters as well as the same password entered in the “password” field. Click to continue »

Tags : , , ,

Mar
20
Show hidden files and folders not working in window xp?

I tried to enable “show hidden files and folder” option in my window xp but after clicking “apply” and “ok” when i returned back to the folder to view hidden files it did not show the hidden files. I tried once again and then again but it did not work. The changes would just disappear upon opening the dialog again. Click to continue »

Mar
06
Simple captcha component for CakePHP

This post is deprecated. Please check this post instead.

Captcha is the basic necessity in today’s data submission processes where numerous spammers are looking for space to occupy with their promos.

There are number of captcha component online and i have created this one to suit my cakephp needs by modifying one simple yet powerful captcha script. Click to continue »

Tags : , ,

Mar
05
TinyMce and Captcha collide in my cakephp application

I was struck in a very strange problem today. I was using captcha component to create and set a captcha session and image for view section. Next is the snippet of create function which i used to load component. I will be pasting JcaptchaComponent source code at the end for anyone who may want to take a look into the matter more precisely (however i feel the componet itself should be quite innocent) Click to continue »

Tags : , , ,

Feb
26
Windows keyboard shortcuts (hot keys)

This post lists keyboard shortcuts that you can use with Windows. I have picked it from Microsoft website for my personal reference. You too can use it. ;) Click to continue »

Tags : , , ,

Feb
01
Convert month name to month number in php

While working with a CJ run reports script i needed to convert “month name” into “month number” so i could store it in the database in date format. After doing some cleaning stuff i was ending with the month name, a three character string as “Jan”,”Mar”,”Apr” etc. Here is the quick work around i applied to get the month number automatically from the month name.

$month_name = "Jan"; //which i get from file name (Range_from_1_Jan_2009_to_3_Mar_2009.txt)
$month_number = "";

for($i=1;$i<=12;$i++){
	if(strtolower(date("M", mktime(0, 0, 0, $i, 1, 0))) == strtolower($month_name)){
		$month_number = $i;
		break;
	}
}

Now as php snippet code line 5 date(“M”, mktime(0, 0, 0, 1, 1, 0))) returns a three letter represantion of month name i get month “1″ if i pass $month_name=”Jan” and so on. If i had full month name like “January” i could make it work by replacing “M” with “F” where “F” format parameter is a full represantion of year name.

Special Note: Do not forget to see user comments down the page to find even smarter solutions :)

Tags : , , , , , ,

Freelance Jobs