⚠ 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

callback after insert



IDe

IDe
  • profile picture
  • Member

Posted 03 June 2015 - 16:41 PM

hello ...

I have this problem ,,, I want to insert in 'traza' after insert in clasificacion... with the purpose of do a trace system of users ...

I have this ...

  if ($this->ion_auth->logged_in() && $this->ion_auth->in_group('admin')) {

            try {

                /* Creamos el objeto */
                $crud = new grocery_CRUD();

                /* Seleccionamos el tema */
                $crud->set_theme('flexigrid');

                /* Seleccionmos el nombre de la tabla de nuestra base de datos */
                $crud->set_table('clasificacion');

                /* Le asignamos un nombre */
                $crud->set_subject('clasificación');

                /* Asignamos el idioma español */
                $crud->set_language('spanish');


                /* Aqui le decimos a grocery que estos campos son obligatorios */
                $crud->required_fields(
                        'id_clasificacion', 'clasificacion'
                );

                /* Aqui le indicamos que campos deseamos mostrar */
                $crud->columns(
                        'clasificacion'
                );

                $crud->callback_after_insert(array($this, 'trazar_after_insert'));
                $usuario = $this->session->userdata('user_id');
                $fecha = mdate();
                
                function trazar_after_insert($post_array, $primary_key) {
                    $traza_insert = array(
                        "id" => $primary_key,
                        "id_usuario" => $usuario,
                        "accion" => "insertó",
                        "fecha" => $fecha
                    );

                    $this->db->insert('traza', $traza_insert);

                    return true;
                }
traza's table have this ...
TABLE `traza` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_usuario` varchar(128) NOT NULL,
  `accion` varchar(128) NOT NULL,
  `fecha` date NOT NULL,
  PRIMARY KEY (`id`),
  KEY `slug` (`id`)


after the insert in clasificacion I can't see nothing in traza's table ... why ??  ,,, please help
 

 

 

 


Paul Savostin

Paul Savostin
  • profile picture
  • Member

Posted 06 June 2015 - 09:42 AM

hello ...

I have this problem ,,, I want to insert in 'traza' after insert in clasificacion... with the purpose of do a trace system of users ...

I have this ...

  if ($this->ion_auth->logged_in() && $this->ion_auth->in_group('admin')) {

            try {

                /* Creamos el objeto */
                $crud = new grocery_CRUD();

                /* Seleccionamos el tema */
                $crud->set_theme('flexigrid');

                /* Seleccionmos el nombre de la tabla de nuestra base de datos */
                $crud->set_table('clasificacion');

                /* Le asignamos un nombre */
                $crud->set_subject('clasificación');

                /* Asignamos el idioma español */
                $crud->set_language('spanish');


                /* Aqui le decimos a grocery que estos campos son obligatorios */
                $crud->required_fields(
                        'id_clasificacion', 'clasificacion'
                );

                /* Aqui le indicamos que campos deseamos mostrar */
                $crud->columns(
                        'clasificacion'
                );

                $crud->callback_after_insert(array($this, 'trazar_after_insert'));
                $usuario = $this->session->userdata('user_id');
                $fecha = mdate();
                
                function trazar_after_insert($post_array, $primary_key) {
                    $traza_insert = array(
                        "id" => $primary_key,
                        "id_usuario" => $usuario,
                        "accion" => "insertó",
                        "fecha" => $fecha
                    );

                    $this->db->insert('traza', $traza_insert);

                    return true;
                }
traza's table have this ...
TABLE `traza` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `id_usuario` varchar(128) NOT NULL,
  `accion` varchar(128) NOT NULL,
  `fecha` date NOT NULL,
  PRIMARY KEY (`id`),
  KEY `slug` (`id`)


after the insert in clasificacion I can't see nothing in traza's table ... why ??  ,,, please help
 


Hi, I dont understand why you add manually ID - "id" => $primary_key, -----> `id` int(11) NOT NULL AUTO_INCREMENT,  !!!!!!!!!