Skip to content
Snippets Groups Projects
Commit cc6cff8a authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Meilleure gestion des NULL

parent 4c59b87e
No related branches found
No related tags found
No related merge requests found
...@@ -338,12 +338,21 @@ class Table ...@@ -338,12 +338,21 @@ class Table
$whereSql .= ' AND '; $whereSql .= ' AND ';
} }
$transVal = ':' . $c;
if (isset($options['columns'][$c]['transformer'])) { if (isset($options['columns'][$c]['transformer'])) {
$transVal = ':' . $c;
$transVal = '(' . sprintf($options['columns'][$c]['transformer'], $transVal) . ')'; $transVal = '(' . sprintf($options['columns'][$c]['transformer'], $transVal) . ')';
}
$whereSql .= $c . ' = ' . $transVal; $whereSql .= $c . ' = ' . $transVal;
$params[$c] = $v; $params[$c] = $v;
}else{
if ($v === null){
$whereSql .= $c . ' IS NULL';
}else{
$transVal = ':' . $c;
$whereSql .= $c . ' = ' . $transVal;
$params[$c] = $v;
}
}
} }
return ' WHERE ' . $whereSql; return ' WHERE ' . $whereSql;
...@@ -406,6 +415,7 @@ class Table ...@@ -406,6 +415,7 @@ class Table
case 'CLOB': case 'CLOB':
return $value; return $value;
case 'DATE': case 'DATE':
if (!$value) return null;
$date = \DateTime::createFromFormat('Y-m-d', $value); $date = \DateTime::createFromFormat('Y-m-d', $value);
$date->setTime(0, 0, 0); $date->setTime(0, 0, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment