/trunk/bibliotheque/dao/Dao.php |
---|
New file |
0,0 → 1,52 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Classe modèle spécifique à l'application, donc d'accés au données, elle ne devrait pas être appelée de l'extérieur. |
* Elle est abstraite donc doit obligatoirement être étendue. |
* |
* @category Php5 |
* @package Referentiel |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright 2010 Tela-Botanica |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL |
* @version SVN: $Id$ |
*/ |
abstract class Dao { |
protected $distinction = '0'; |
protected $limite_debut = null; |
protected $limite_nbre = null; |
protected $url_jrest = null; |
public function __construct() { |
$this->url_jrest = config::get('url_jrest'); |
} |
public function avoirLimitation() { |
$limitation = false; |
if (!is_null($this->limite_debut) && !is_null($this->limite_nbre)) { |
$limitation = true; |
} |
return $limitation; |
} |
public function setDistinction($distinct) { |
$this->distinction = $distinct; |
} |
public function getDistinction() { |
return $this->distinction; |
} |
public function setLimitation($limite_debut, $limite_nbre) { |
$this->limite_debut = $limite_debut; |
$this->limite_nbre = $limite_nbre; |
} |
public function getLimiteDebut() { |
return $this->limite_debut; |
} |
public function getLimiteNbre() { |
return $this->limite_nbre; |
} |
} |
/trunk/bibliotheque/dao/ReferentielDao.php |
---|
New file |
0,0 → 1,64 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Modèle d'accès à la base de données des Référentiels. |
* Permet d'accèder au données d'un référentiel. |
* |
* @package Referentiel |
* @category Php 5.2 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright 2010 Tela-Botanica |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL |
* @version SVN: $Id$ |
* |
*/ |
class ReferentielDao extends Dao { |
const SERVICE = 'RefReferentiel'; |
/** |
* Retourne l'ensemble des information sur les colonnes d'une table. |
* |
* @param string le nom de la table. |
* @return array un tableau contenant les informations sur les colonnes de la table. |
*/ |
public function getTout($code_projet) { |
$url = $this->url_jrest.self::SERVICE."/Tout/$code_projet"; |
$json = file_get_contents($url); |
$noms = json_decode($json, true); |
/* |
$noms = array(); |
$pas = 20000; |
$max = $this->getNombre($code_projet); |
for ($i = 0; $i < $max; $i = $i + $pas) { |
$start = ($i != 0) ? ($i+1): $i; |
$limit = $i + $pas; |
$url_limitee = $url."?start=$start&limit=$limit"; |
Debug::printr("Récupération des données de $start à $limit"); |
$json = file_get_contents($url_limitee); |
$enregistrements = json_decode($json, true); |
$noms = array_merge($noms, $enregistrements); |
}*/ |
return $noms; |
} |
/** |
* Retourne le nombre de noms présents dans la table de travail du référentiel. |
* |
* @param string le code du référentiel. |
* @return int le nombre de noms. |
*/ |
public function getNombre($code_projet) { |
$url = $this->url_jrest.self::SERVICE."/Nombre/$code_projet"; |
$json = file_get_contents($url); |
$nbre = json_decode($json, true); |
return $nbre; |
} |
} |
?> |
/trunk/bibliotheque/dao/TableStructureDao.php |
---|
New file |
0,0 → 1,45 |
<?php |
// declare(encoding='UTF-8'); |
/** |
* Modèle d'accès à la base de données des Référentiels. |
* Service concernant les tests |
* |
* @package Referentiel |
* @category Php 5.2 |
* @author Jean-Pascal MILCENT <jpm@tela-botanica.org> |
* @copyright 2010 Tela-Botanica |
* @license http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL |
* @license http://www.gnu.org/licenses/gpl.html Licence GNU-GPL |
* @version SVN: $Id$ |
* |
*/ |
class TableStructureDao extends Dao { |
const SERVICE = 'RefTableStructure'; |
/** |
* Retourne l'ensemble des information sur les colonnes d'une table. |
* |
* @param string le nom de la table. |
* @return array un tableau contenant les informations sur les colonnes de la table. |
*/ |
public function getColonnes($table) { |
$url = $this->url_jrest.self::SERVICE."/colonnes/$table"; |
$json = file_get_contents($url); |
$donnees = json_decode($json, true); |
return $donnees['colonnes']; |
} |
/** |
* Retourne l'ensemble des information d'analyse de la structure d'une table. |
* |
* @param string le nom de la table. |
* @return array un tableau contenant les informations de l'analyse de la table. |
*/ |
public function getAnalyse($table) { |
$url = $this->url_jrest.self::SERVICE."/analyse/$table"; |
$json = file_get_contents($url); |
$donnees = json_decode($json, true); |
return $donnees['analyses']; |
} |
} |
?> |