title: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails
body: <p>I use idiorm + slim</p>
  
  <p>I realize the following update query, but I try in the console phpmyadmin and it works.</p>
  
  <pre><code>update empleado set `nieempleado`='11111', nombre="Mickael", apellido1="aaa", apellido2="bbb", email="ma@gmail.com", puesto=0 where id = 1
  </code></pre>
  
  <p>but in idiorm error SQLSTATE[23000]</p>
  
  <p>What´s the problem?</p>
  
  <pre><code>if(count($error)==0)
          {
  
              $empleado = ORM::for_table('empleado')-&gt;find_one($id);
              $empleado-&gt;nieempleado = $nie;
              $empleado-&gt;nombre = $nombre;
              $empleado-&gt;apellido1 = $apellido1;
              $empleado-&gt;apellido2 = $apellido2;
              $empleado-&gt;email = $email;
              $empleado-&gt;puesto = $puesto;   
              if(!empty($telefono))
              {
                  $empleado-&gt;telefono = $telefono;
              }
              if($usuario!=='')
              {
                  $empleado-&gt;usuario_idusuario = $usuario;
              }  
              $empleado-&gt;save();
              $app-&gt;redirect($app-&gt;urlFor('employeeList'));
          }
  </code></pre>
  
  <p>My tables are usuario:</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `usuario` (
             `id` int(11) UNSIGNED AUTO_INCREMENT,
             `username` varchar(45) NOT NULL,
             `contrasenia` varchar(255) NOT NULL,
             `email` varchar(45) NOT NULL,
             `admin` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
              PRIMARY KEY (`id`)) 
              ENGINE = InnoDB;
  </code></pre>
  
  <p>and empleado</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `empleado` (
             `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT,
             `nieempleado` VARCHAR(10) NOT NULL,
             `nombre` VARCHAR(45) NOT NULL,
             `apellido1` VARCHAR(50) NOT NULL,
             `apellido2` VARCHAR(50) NOT NULL,
             `email` VARCHAR(100) NOT NULL,
             `telefono` VARCHAR(10) NULL,
             `puesto` int(11) NOT NULL,
             `usuario_idusuario` int(11) UNSIGNED,
              PRIMARY KEY (`id`),
              INDEX `fk_empleado_usuario1_idx` (`usuario_idusuario` ASC),
              CONSTRAINT `fk_empleado_usuario_id_fk`
              FOREIGN KEY (`usuario_idusuario`)
              REFERENCES `usuario` (`id`)
              ON DELETE CASCADE
              ON UPDATE CASCADE
              )ENGINE = InnoDB;
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>Type: PDOException
  Code: 23000
  Message: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`viversoft`.`empleado`, CONSTRAINT `fk_empleado_usuario_id_fk` FOREIGN KEY (`usuario_idusuario`) REFERENCES `usuario` (`id`) ON DELETE CASCADE ON UPDATE CASCADE)
  File: C:\wamp\www\viver\vendor\j4mie\idiorm\idiorm.php
  Line: 413
  Trace
  
  #0 C:\wamp\www\viver\vendor\j4mie\idiorm\idiorm.php(413): PDOStatement-&gt;execute(Array)
  #1 C:\wamp\www\viver\vendor\j4mie\idiorm\idiorm.php(1735): ORM::_execute('UPDATE `emplead...', Array, 'default')
  #2 C:\wamp\www\viver\routes\employees.php(213): ORM-&gt;save()
  #3 [internal function]: {closure}('1')
  #4 C:\wamp\www\viver\vendor\slim\slim\Slim\Route.php(462): call_user_func_array(Object(Closure), Array)
  #5 C:\wamp\www\viver\vendor\slim\slim\Slim\Slim.php(1326): Slim\Route-&gt;dispatch()
  #6 C:\wamp\www\viver\vendor\slim\slim\Slim\Middleware\Flash.php(85): Slim\Slim-&gt;call()
  #7 C:\wamp\www\viver\vendor\slim\slim\Slim\Middleware\MethodOverride.php(92): Slim\Middleware\Flash-&gt;call()
  #8 C:\wamp\www\viver\vendor\slim\slim\Slim\Middleware\PrettyExceptions.php(67): Slim\Middleware\MethodOverride-&gt;call()
  #9 C:\wamp\www\viver\vendor\slim\slim\Slim\Slim.php(1271): Slim\Middleware\PrettyExceptions-&gt;call()
  #10 C:\wamp\www\viver\public\index.php(55): Slim\Slim-&gt;run()
  #11 {main}
  </code></pre>