⚠ 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 forum is read-only and soon will be archived. ⚠


Getting problem with relation_n_n

set_relation_n_n database

  • Please log in to reply
1 reply to this topic

#1 Carlos Cortes

Carlos Cortes

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 30 January 2013 - 11:52 PM

Hi,

I'm starting to use the GC plugin for CI and it is awesome!, but now im getting some error when i try to add a new registry to the database but not when i edit one.
This is the error:

<p>Error Number: 1452</p><p>Cannot add or update a child row: a foreign key constraint fails (`josuedor_bd_investigaciones`.`nombre_grupo_has_usuarios`, CONSTRAINT `fk_nombre_grupo_has_invesstigadores_invesstigadores1` FOREIGN KEY (`usuarios_idUsuario`) REFERENCES `usuarios` (`idUsuari)</p><p>INSERT INTO `nombre_grupo_has_usuarios` (`usuarios_idUsuario`, `nombre_grupo_idgrupo`) VALUES (0, '111')</p><p>Filename: C:\xampp\htdocs\practicas\proyecto-practicas\system\database\DB_driver.php</p><p>Line Number: 330</p></div>


And this is the code of the relation:

$crud->set_relation_n_n('grupo','nombre_grupo_has_usuarios','nombre_grupo','usuarios_idUsuario','nombre_grupo_idgrupo','nombre_g');

Just in case, the fields:

$crud->fields('idUsuario','nombre','apellido','direccion','fijo','celular','email','grupo');

Thank you for your help, i had been trying this all day but omg. :unsure:

#2 goFrendiAsgard

goFrendiAsgard

    Advanced Member

  • Members
  • PipPipPip
  • 137 posts

Posted 01 February 2013 - 01:45 AM

I've similar problem when using "varchar" field as primary key
Can you make sure that all of your primary key table is "integer" and "auto-increment"?

And, for relation_n_n, have you check this documentation: http://www.grocerycr...et_relation_n_n





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users