Codeigniter - Custom Validator Function with Arguments.

I had a situation where i have to pass parameters to a custom validator function of Codeigniter.
after experimenting i got a solution to add second argument in custom validator function definition.
 public function isNotPastDate($str,$parameter){

     #Loading  CI Instance
        $CI = & get_instance();
        $CI->load->database();
  #setting up the initiator filed name and data.
       
        $date = $CI->input->post($parameter, true);
        $fieldname = ($parameter == 'to')?"To":"From";

        if ((date('Y-m-d', strtotime($date)) < date('Y-m-d')))
        {
            $CI->form_validation->set_message('isNotPastDate', $fieldname.' Date is a Past date.');
         return false;
        }
        else
        {
            return true;
        }
    }

with the rule config :

array(
    array(
        'field' => 'from',
        'label' => 'From Date',
        'rules' => 'required|trim|xss_clean|dateRangeValidation|isNotPastDate[from]'
    ),
    array(
        'field' => 'to',
        'label' => 'To Date',
        'rules' => 'required|trim|xss_clean|isNotPastDate[to]'
    ),);

Transfer a data from one table to another with SQL

INSERT INTO attendance_process (empid,DATE,time_in,time_out,
late_time,early_time,
STATUS,total_hours)

SELECT empid, DATE , clock_in, clock_out , late, early, 
CASE WHEN (absent = 'true') THEN 6 
WHEN (TIME_TO_SEC(clock_in)>0 AND TIME_TO_SEC(clock_out)=0) THEN 4
WHEN (TIME_TO_SEC(clock_in)=0 AND TIME_TO_SEC(clock_out)>0) THEN 4
WHEN (TIME_TO_SEC(early) > 0) THEN 3
WHEN (TIME_TO_SEC(late) > 0 ) THEN 2

ELSE 1 END AS STATUS, time_spent 

FROM attendance

Sum time field of MySql

a query to show sum of time filed in MySql :

SELECT SEC_TO_TIME(SUM(TIME_TO_SEC(hour_spent))) AS
total_Hours_spent 
FROM attendance 
WHERE absent='false' AND employ_id='3052' 
AND DATE_FORMAT(DATE,'%Y-%m')='2011-07';