⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

How to save the return callback value to my database?



xmyownprisonx
  • profile picture
  • Member

Posted 04 September 2016 - 13:36 PM

I have a column like this:

$crud->columns('student_no','last_name','first_name','middle_name','faculty_name','subject_desc','first_qtr','second_qtr','final_grade');

 

$crud->display_as('final_grade','Final Grade');

 

 

//My Callback column

 $crud->callback_column('final_grade',array($this,'callback_fg'));

 

 

//my callback function

public function callback_fg($value, $row)
        {
            $first_qtr = $row->first_qtr;
            $second_qtr = $row->second_qtr;
          
            
            $final_grade = round(($first_qtr + $second_qtr)/2);

                   
            if($second_qtr == 0)
            {
                return "input 2nd_qtr";
            }
           
            else {
                return $final_grade;

            }
            

        }

 


portapipe
  • profile picture
  • Member

Posted 09 September 2016 - 20:37 PM

You just need to make an SQL query into the callback_fg function like:
$this->db->query("INSERT INTO.......")

It's a standard CodeIgniter db query :)