From e1a524faee8ed525cd317793e49f83e2b7e00eeb Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 20 Feb 2017 09:57:26 +0100 Subject: [PATCH] [Fixed] Creation de machine (orm, insert NULL values) --- build/database/repo/machine.php | 4 ++-- build/orm/core/Rows.php | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/build/database/repo/machine.php b/build/database/repo/machine.php index c9f002c..efc27b1 100755 --- a/build/database/repo/machine.php +++ b/build/database/repo/machine.php @@ -27,8 +27,8 @@ 'id_machine' => Rows::INSERT_DEFAULT, 'id_warehouse' => $id_warehouse, 'name' => $name, - 'token' => Rows::NULL, - 'unlock_code' => Rows::NULL + 'token' => null, + 'unlock_code' => null ]); // Si erreur (car name doit être unique) diff --git a/build/orm/core/Rows.php b/build/orm/core/Rows.php index 75ec804..0bd7592 100755 --- a/build/orm/core/Rows.php +++ b/build/orm/core/Rows.php @@ -664,6 +664,8 @@ foreach($set as $field=>$value){ + if( is_null($value) ) continue; + $type = $this->schema['columns'][$field]['type']; // {1} Si de type INT/FLOAT et pas numérique, on retire le champ // @@ -713,6 +715,7 @@ // Si l'entrée est donnée if( isset($set[$field]) ) if( $set[$field] == self::INSERT_DEFAULT ) $requestS .= 'DEFAULT'; // On insère directement les valeurs 'DEFAULT' + else if( is_null($set[$field]) ) $requestS .= 'NULL'; else $requestS .= ':insert_'.$field.'_'.$i; else $requestS .= 'DEFAULT';