Subversion Repositories Applications.referentiel

Rev

Rev 18 | Rev 22 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 20
1
<?php
1
<?php
2
// declare(encoding='UTF-8');
2
// declare(encoding='UTF-8');
3
/**
3
/**
4
 * Modèle d'accès à la base de données des Référentiels.
4
 * Modèle d'accès à la base de données des Référentiels.
5
 * Permet d'accèder au données d'un référentiel.
5
 * Permet d'accèder au données d'un référentiel.
6
 *
6
 *
7
 * @package		Referentiel
7
 * @package		Referentiel
8
 * @category	Php 5.2
8
 * @category	Php 5.2
9
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
9
 * @author		Jean-Pascal MILCENT <jpm@tela-botanica.org>
10
 * @copyright	2010 Tela-Botanica
10
 * @copyright	2010 Tela-Botanica
11
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
11
 * @license		http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
12
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
12
 * @license		http://www.gnu.org/licenses/gpl.html Licence GNU-GPL
13
 * @version		SVN: $Id$
13
 * @version		SVN: $Id$
14
 *
14
 *
15
 */
15
 */
16
class ReferentielDao extends AppliModele {
16
class ReferentielDao extends Dao {
17
	const SERVICE = 'RefReferentiel';
17
	const SERVICE = 'RefReferentiel';
18
	
18
	
19
	/**
19
	/**
20
	 * Retourne l'ensemble des information sur les colonnes d'une table.
20
	 * Retourne l'ensemble des information sur les colonnes d'une table.
21
	 * 
21
	 * 
22
	 * @param string le nom de la table.
22
	 * @param string le nom de la table.
23
	 * @return array un tableau contenant les informations sur les colonnes de la table.
23
	 * @return array un tableau contenant les informations sur les colonnes de la table.
24
	 */
24
	 */
25
	public function getTout($code_projet) {
25
	public function getTout($code_projet) {
26
		$url = $this->url_jrest.self::SERVICE."/Tout/$code_projet";
26
		$url = $this->url_jrest.self::SERVICE."/Tout/$code_projet";
27
		
27
		
28
		$json = file_get_contents($url);
28
		$json = file_get_contents($url);
29
		$noms = json_decode($json, true);
29
		$noms = json_decode($json, true);
30
		
30
		
31
		/*
31
		/*
32
		$noms = array();
32
		$noms = array();
33
		$pas = 20000;
33
		$pas = 20000;
34
		$max = $this->getNombre($code_projet);
34
		$max = $this->getNombre($code_projet);
35
		for ($i = 0; $i < $max; $i = $i + $pas) {
35
		for ($i = 0; $i < $max; $i = $i + $pas) {
36
			$start = ($i != 0) ? ($i+1): $i;
36
			$start = ($i != 0) ? ($i+1): $i;
37
			$limit = $i + $pas;
37
			$limit = $i + $pas;
38
			$url_limitee = $url."?start=$start&limit=$limit";
38
			$url_limitee = $url."?start=$start&limit=$limit";
39
			Debug::printr("Récupération des données de $start à $limit");
39
			Debug::printr("Récupération des données de $start à $limit");
40
			$json = file_get_contents($url_limitee);
40
			$json = file_get_contents($url_limitee);
41
			
41
			
42
			$enregistrements = json_decode($json, true);
42
			$enregistrements = json_decode($json, true);
43
			$noms = array_merge($noms, $enregistrements);
43
			$noms = array_merge($noms, $enregistrements);
44
		}*/
44
		}*/
45
		
45
		
46
		return $noms;
46
		return $noms;
47
	}
47
	}
48
	
48
	
49
	/**
49
	/**
50
	 * Retourne le nombre de noms présents dans la table de travail du référentiel.
50
	 * Retourne le nombre de noms présents dans la table de travail du référentiel.
51
	 * 
51
	 * 
52
	 * @param string le code du référentiel.
52
	 * @param string le code du référentiel.
53
	 * @return int le nombre de noms.
53
	 * @return int le nombre de noms.
54
	 */
54
	 */
55
	public function getNombre($code_projet) {
55
	public function getNombre($code_projet) {
56
		$url = $this->url_jrest.self::SERVICE."/Nombre/$code_projet";
56
		$url = $this->url_jrest.self::SERVICE."/Nombre/$code_projet";
57
		
57
		
58
		$json = file_get_contents($url);
58
		$json = file_get_contents($url);
59
		$nbre = json_decode($json, true);
59
		$nbre = json_decode($json, true);
60
		
60
		
61
		return $nbre;
61
		return $nbre;
62
	}
62
	}
63
}
63
}
64
?>
64
?>