Commits

Vittore Zen committed 98ac352

Modify in according to new version of adodb without fetch assoc

Comments (0)

Files changed (1)

externals/json_services/segremat/index.php

 <?php
-
 $serviceKey = "lkhjglkh78435vlsd";
 $key = $_REQUEST['key'];
 if ($key != md5($serviceKey . date('Ymd'))) {
-    echo json_encode('no valid key');
+    echo json_encode('1.no valid key');
     die;
 }
 include ( 'lib/adodb5/adodb.inc.php');
 $filedb = 'C:\inetpub\segremat\Anagrafe.mdb';
 set_time_limit(0);
-$db = NewADOConnection('access');
 
+$db = NewADOConnection('access');
 $db->debug = false;
 $dsn = "Driver={Microsoft Access Driver (*.mdb)};Dbq=$filedb;Uid=Admin;Pwd=;";
 $db->Connect($dsn);
-$db->SetFetchMode(ADODB_FETCH_ASSOC);
 $sql = "SELECT Anagrafica.CodiceAlunno, 
     Anagrafica.Nome, Anagrafica.Cognome, Anagrafica.MailStudente, 
     Anagrafica.CF_Alunno, Anagrafica.DataNascita, Anagrafica.Classe, 
     FROM Anagrafica 
     WHERE Anagrafica.TipoNominativo=1
     ORDER BY Anagrafica.Cognome ASC, Anagrafica.Nome ASC;";
-$recordSet = & $db->Execute($sql);
+$recordSet = $db->Execute($sql);
 $elenco = array();
 while (!$recordSet->EOF) {
-    $nome = $recordSet->fields['Nome'];
-    $Cognome = $recordSet->fields['Cognome'];
-    $settoreClasse = $recordSet->fields['SettoreClasse'];
-    $elenco[$recordSet->fields['CF_Alunno']] = array(
-                'id' => $recordSet->fields['CF_Alunno'],
-                'firstname' => trim(ucwords(strtolower($recordSet->fields['Nome']))),
-                'lastname' => trim(ucwords(strtolower($recordSet->fields['Cognome']))),
-                'email' => trim(strtolower($recordSet->fields['MailStudente'])),
-                'group' => trim(str_replace('^', '', $recordSet->fields['SettoreClasse']))
+    $CodiceAlunno = $recordSet->fields[0];
+    $Nome = $recordSet->fields[1];
+    $Cognome = $recordSet->fields[2];
+    $MailStudente = $recordSet->fields[3];
+    $CF_Alunno = $recordSet->fields[4];
+    $DataNascita = $recordSet->fields[5];
+    $Classe = $recordSet->fields[6];
+    $Settore = $recordSet->fields[7];
+    $SettoreClasse = $recordSet->fields[8];
+
+    $elenco[$CF_Alunno] = array(
+                'id' => $CF_Alunno,
+                'firstname' => trim(ucwords(strtolower($Nome))),
+                'lastname' => trim(ucwords(strtolower($Cognome))),
+                'email' => trim(strtolower($MailStudente)),
+                'group' => trim(str_replace('^', '', $SettoreClasse))
     );
     $recordSet->MoveNext();
 }
     WHERE Anagrafica.TipoNominativo=1 AND (Anagrafica.MailStudente='' OR Anagrafica.MailStudente IS NULL)";
 $recordSet = & $db->Execute($sql);
 while (!$recordSet->EOF) {
-    $elenco[$recordSet->fields['CF_Alunno']]['email'] = 'email@non.indicata.it';
+    $CF_Alunno = $recordSet->fields[0];
+    $elenco[$CF_Alunno]['email'] = 'email@non.indicata.it';
     $recordSet->MoveNext();
 }
 $recordSet->Close();