diff --git a/build/lightdb/storage/dictionary.json b/build/lightdb/storage/dictionary.json index ffa5b89..513f1a4 100644 --- a/build/lightdb/storage/dictionary.json +++ b/build/lightdb/storage/dictionary.json @@ -4,7 +4,6 @@ "logs": { "direction": { "0": "INCOMING", "1": "OUTGOING", "2": "MISSED" }, "type": { "0": "PHONE", "1": "SMS" } - }, @@ -152,7 +151,7 @@ "6": "Top 10 de l'historique Facebook", "7": "Top 10 de Facebook Messenger" } - + } } diff --git a/build/orm/core/Rows.php b/build/orm/core/Rows.php index 9c7397b..e748764 100644 --- a/build/orm/core/Rows.php +++ b/build/orm/core/Rows.php @@ -271,6 +271,10 @@ if( !is_null($func) && !in_array($func, $funcList) ) return $this; + // If CONCAT -> force type to TEXT + if( $func === Rows::SEL_CONCAT ) + $this->schema['columns'][$field]['type'] = 'text'; + /* (4) On met la valeur par défaut à @distinct si type mauvais */ $distinct = !is_bool($distinct) ? false : $distinct; diff --git a/public_html/test/Lab-Surveys-Import.php b/public_html/test/Lab-Surveys-Import.php index 3311530..804c767 100644 --- a/public_html/test/Lab-Surveys-Import.php +++ b/public_html/test/Lab-Surveys-Import.php @@ -17,40 +17,167 @@ /* [2] Requests on lab-surveys =========================================================*/ - $lisst = Table::get('laboratoires', 'lab-surveys') - // ->select('idLaboratoire') - ->whereIntitule('LISST'); + function fetchAllData(){ + $lisst = Table::get('laboratoires', 'lab-surveys') + ->whereIntitule('LISST'); - $etudes = Table::get('etudes', 'lab-surveys') - // ->select('idEtude') - ->join('idLaboratoire', $lisst) - ->orderby('idEtude') - ->unique(); + $etudes = Table::get('etudes', 'lab-surveys') + ->join('idLaboratoire', $lisst) + ->orderby('idEtude') + ->unique(); - $fiches = Table::get('fiches', 'lab-surveys') - ->select('idFiche') - ->orderby('idFiche') - ->join('idEtude', $etudes); + $fiches = Table::get('fiches', 'lab-surveys') + ->select('idFiche') + ->orderby('idFiche') + ->join('idEtude', $etudes); - $questions = Table::get('questionsFiches', 'lab-surveys') - ->select('idQuestionFiche') - ->select('intitule', null, null, 'question') - ->orderby('idQuestionFiche') - // ->unique() - ->join('idFiche', $fiches); + $questions = Table::get('questionsFiches', 'lab-surveys') + ->select('idQuestionFiche') + ->select('intitule', null, null, 'question') + ->orderby('idQuestionFiche') + ->join('idFiche', $fiches); - $repAtt = Table::get('reponsesAttenduesFiches', 'lab-surveys') - ->select('intitule', Rows::SEL_CONCAT, null, 'reponses') - ->orderby('idReponseAttendueFiche') - ->join('idQuestionFiche', $questions); + $repAtt = Table::get('reponsesAttenduesFiches', 'lab-surveys') + ->select('intitule', Rows::SEL_CONCAT, null, 'possible') + ->join('idQuestionFiche', $questions) + ->orderby('idReponseAttendueFiche'); - $sujets = Table::get('sujets', 'lab-surveys') - ->select('idSujet') - ->select('pseudo'); + $sujets = Table::get('sujets', 'lab-surveys') + ->select('idSujet') + ->select('pseudo') + ->orderby('idSujet'); + + $repSuj = Table::get('reponsesFiches', 'lab-surveys') + ->select('intitule', null, null, 'reponse') + ->join('idSujet', $sujets) + ->join('idQuestionFiche', $repAtt); + + var_dump( $repSuj->fetch() ); + } + + + function fetchSujets(){ + $lisst = Table::get('laboratoires', 'lab-surveys') + ->whereIntitule('LISST'); + + $etudes = Table::get('etudes', 'lab-surveys') + ->join('idLaboratoire', $lisst) + ->orderby('idEtude') + ->unique(); + + $sujets = Table::get('sujets', 'lab-surveys') + ->select('idSujet') + ->select('pseudo') + ->join('idEtude', $lisst) + ->orderby('idSujet'); + + var_dump( $sujets->fetch() ); + } + + + function fetchNbQuestionsPerFiche(){ + $lisst = Table::get('laboratoires', 'lab-surveys') + ->whereIntitule('LISST'); + + $etudes = Table::get('etudes', 'lab-surveys') + ->join('idLaboratoire', $lisst) + ->orderby('idEtude') + ->unique(); + + $fiches = Table::get('fiches', 'lab-surveys') + ->select('idFiche') + ->orderby('idFiche') + ->join('idEtude', $etudes); + + $questions = Table::get('questionsFiches', 'lab-surveys') + ->select('idQuestionFiche', Rows::SEL_COUNT) + ->join('idFiche', $fiches); + + var_dump( $questions->fetch() ); + } + + + function fetchFicheComplete(){ + $lisst = Table::get('laboratoires', 'lab-surveys') + ->whereIntitule('LISST'); + + $etudes = Table::get('etudes', 'lab-surveys') + ->join('idLaboratoire', $lisst) + ->orderby('idEtude') + ->unique(); + + $fiche = Table::get('fiches', 'lab-surveys') + ->select('idFiche') + ->orderby('idFiche') + ->join('idEtude', $etudes) + ->unique(); + + $questions = Table::get('questionsFiches', 'lab-surveys') + ->select('idQuestionFiche') + ->select('intitule') + ->orderby('idQuestionFiche') + ->join('idFiche', $fiche); + + $rep = Table::get('reponsesAttenduesFiches', 'lab-surveys') + ->select('idReponseAttendueFiche', Rows::SEL_CONCAT, null, 'reponsesid') + ->select('intitule', Rows::SEL_CONCAT, null, 'reponses') + ->orderby('idReponseAttendueFiche') + ->join('idQuestionFiche', $questions); + + var_dump( $rep->fetch() ); + } + + + function fetchRelations(){ + $lisst = Table::get('laboratoires', 'lab-surveys') + ->whereIntitule('LISST'); + + $etudes = Table::get('etudes', 'lab-surveys') + ->join('idLaboratoire', $lisst) + ->orderby('idEtude') + ->unique(); + + $A = Table::get('sujets', 'lab-surveys') + ->select('pseudo', null, null, 'A') + ->join('idEtude', $lisst) + ->orderby('idSujet'); + + $B = Table::get('sujets', 'lab-surveys') + ->select('pseudo', null, null, 'B') + ->join('idEtude', $lisst) + ->orderby('idSujet'); + + $cate = Table::get('categoriesRelations', 'lab-surveys') + ->select('intitule', null, null, 'categorie'); + + $rel = Table::get('relations', 'lab-surveys') + ->join('idSujetA', $A) + ->join('idSujetB', $B) + ->join('idCategorieRelation', $cate); + + var_dump( $rel->fetch() ); + }fetchRelations(); + + + function idQuestionToKey($idQuestion){ + switch($idQuestion){ + case 3: return 'sexe'; break; + case 6: return 'studies1'; break; + case 5: return 'famsit'; break; + case 12: return 'context'; break; + case 7: return 'reltype'; break; + case 10: return 'dist'; break; + case 15: return 'freq[face]'; break; + case 16: return 'freq[skype]'; break; + case 17: return 'freq[sms]'; break; + case 18: return 'freq[mail]'; break; + case 19: return 'freq[facebook]'; break; + } + + } - var_dump( $v=$repAtt->fetch() ); ?>