From 3ed81c4a7b3a67e12580619a2ad38ffeb6b479e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jefferson=20Sim=C3=A3o=20Gon=C3=A7alves?= Date: Tue, 15 Oct 2019 14:52:33 -0300 Subject: [PATCH] Update DataTablesComponent.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verificando o tipo da coluna se é númerica para fazer o devido cast para validar a pesquisa --- .../Component/DataTablesComponent.php | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Controller/Component/DataTablesComponent.php b/src/Controller/Component/DataTablesComponent.php index 4871c0d..ab47122 100644 --- a/src/Controller/Component/DataTablesComponent.php +++ b/src/Controller/Component/DataTablesComponent.php @@ -315,6 +315,30 @@ private function _addCondition($column, $value, $type = 'and') $column = substr($column, $pos + 1); } + $columnDesc = $table->getSchema()->getColumn($column); + $columnType = $columnDesc['type']; + if ($columnType !== 'string' && $columnType !== 'text') { + try { + switch ($columnType) { + case "tinyinteger": + case "smallinteger": + case "integer": + case "biginteger": + $value = intval($value); + break; + case "decimal": + case "float": + $value = floatval($value); + break; + } + if ($value === null) { + return; + } + } catch (\Exception $e) { + return; + } + } + $textCast = ""; /* build condition */