From 23c62e940fe308f32ee3a3496d66316b95a1a370 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Mon, 25 Jul 2016 10:53:24 +0200 Subject: [PATCH] ORM: Aucune gestion des types de retours 'format()' des tables de jointures --- manager/ORM/Rows.php | 5 +++-- manager/ORM/SQLBuilder.php | 5 ++++- test/automate.php | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/manager/ORM/Rows.php b/manager/ORM/Rows.php index f2d48ec..5d1da63 100644 --- a/manager/ORM/Rows.php +++ b/manager/ORM/Rows.php @@ -880,8 +880,8 @@ /* (2) On compose la requête */ $requestString = SQLBuilder::BUILD($requestS).';'; - var_dump($requestS); var_dump($requestString); + var_dump($bound); /* (3) On prépare la requête */ $request = Database::getPDO()->prepare($requestString); @@ -973,7 +973,8 @@ else if( $existingColumns[$index]['type'] == 'float' ) $formatted[$i][$index] = floatval( $value ); - }else // Si pas dans le schéma, on le retire + // Si pas non plus une aggrégation et si indice numérique, on le retire + }else if( !preg_match('/^agg_.+/', $index) && is_numeric($index) ) unset($formatted[$i][$index]); diff --git a/manager/ORM/SQLBuilder.php b/manager/ORM/SQLBuilder.php index 2442b28..67e002f 100644 --- a/manager/ORM/SQLBuilder.php +++ b/manager/ORM/SQLBuilder.php @@ -274,7 +274,10 @@ /* (4) On ajoute l'alias */ - $sql .= "$fieldStr"; + if( isset($select[0]) && !is_null($select[0]) ) + $sql .= "$fieldStr as agg_$field"; + else + $sql .= "$fieldStr"; $c++; diff --git a/test/automate.php b/test/automate.php index 96a30f5..b76c050 100755 --- a/test/automate.php +++ b/test/automate.php @@ -490,12 +490,12 @@ $mcm = Table::get('machine_cluster_merge') ->join('id_machine', $m); - $a = Table::get('action_merge') + $am= Table::get('action_merge') ->join('id_source', $ucm) ->join('id_target', $mcm) ->select('id_action', Rows::SEL_CONCAT, Rows::SEL_DISTINCT); - var_dump($a->fetch()); + var_dump($am->fetch()); // $a = new ModuleRequest('authentificationDefault/warehouse', [