Update and insert ONLY in a different table, not the "main" one

Hi all,

I have tried several workarounds but still have not found a solution. The use case: a tool for managing dictionaries. The list of content to be translated belong to a column of a table previusly selected by the user; the dictionary table is in common of all the possible data content tables and databases. I need to list in the datagrid all the original content independently if it has been already trasnlated or not; if not the translation column will be empty. Therefore te “main” controller DB will be the table the content of which need to be translated in order to have also the rows that have not already been translated. If I had used instead as controller main table the dictionary one, I would have missed all the rows of the original content that have not already been translated. In the updated/insert form I will have the pertinent original content fields that are not modifiable; and some custom fields to write the translation.

        // Main DB of this controller

        $this->db = $this->load->database($this->main_db_info['default_db_name'],true);

        $this->grocery_crud->set_table($this->main_db_info['default_table_name']);

The data to be inserted or updated is only the data coming from the custom fields that are not referred to the “main table” with the content to be translated, they belong to the dictionary table. Therefore, the ‘default_table_name’ shall be not updated nor shall it be inserted by new rows. I tried to use the following code

       $this->grocery_crud->callback_before_update(array($this,'_callback_before_update_translation'));



    function _callback_before_update_translation($post_array, $primary_key){


        // Update and insert operatio

ns should be customized here since the main DB and table refer to
        // the content to be translated, not to the translated content. 

        // distinguish the updated and insert case
        // update case
        if(!empty($post_array['dictionary_content_id'])){

            $query = "UPDATE ".$this->DBVariables['multilanguage_DB_name'].".dictionary_content \n"

                    ."SET dictionaries_id = ".$post_array['dictionaries_id'].", main_language_content_row_id = ".$primary_key.", translated_content =".$this->db->escape($post_array['translated_content']).", last_modified = '".date("Y-m-d H:i:s")."', last_modification_admin_id = ".$_SESSION['admin_id']." \n"

                    ."WHERE id = ".$post_array['dictionary_content_id'];

            $query_res = $this->DBVariables['multilanguage_DB']->query($query);

        }

        // insert first time case
        else{

        }

        $post_array = array();
       // $post_array['id'] = $primary_key;
        return $post_array;


    }

The code works properly, the dictionary table is correctly updated, but I get an internal error 500 and the resulting Datagrid is not shown, the browser remains on the web form page. I empty the $post_array to prevent undesired updating of the “main table” and also tried to set $post_array[‘id’] = $primary_key as a workaround to say “update nothing of the main table row with id equal to…:” but still I have the same error. Any idea?