Résolution dépendance BDD

This commit is contained in:
Michael RICOIS 2013-02-19 15:05:16 +00:00
parent 1bf4300ad1
commit db52a51fd2
2 changed files with 47 additions and 28 deletions

View File

@ -248,19 +248,22 @@ $tabDico = array(
);
//MetadataCache pour la base de données
$frontendOptions = array(
'lifetime' => 14400,
'automatic_serialization' => true
);
$backendOptions = array();
$cache = Zend_Cache::factory('Core','Apc', $frontendOptions, $backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
if (ini_get('apc.enable_cli')) {
$frontendOptions = array(
'lifetime' => 14400,
'automatic_serialization' => true
);
$backendOptions = array();
$cache = Zend_Cache::factory('Core','Apc', $frontendOptions, $backendOptions);
Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
}
//Définition bdd local
$config = new Zend_Config($application->getOptions());
Zend_Registry::set('config', $config);
try {
$db = Zend_Db::factory($config->profil->db->local);
$dbJo = Zend_Db::factory($config->profil->db->jo);
} catch ( Exception $e ) {
exit ( $e->getMessage() );
}
@ -736,7 +739,7 @@ foreach($tabIdentifiant as $item)
//Trier pour la sortie
$nbLine = $extendNbRow - $row;
for($i=0;$i<=$nbLine;$i++) {
for($i=0;$i<$nbLine;$i++) {
$tabSortie = array();
foreach($tabEntete as $key){
$tabSortie[] = isset($tabData[$row+i][$key]) ? $tabData[$row+$i][$key] : '';
@ -1493,9 +1496,15 @@ function actionnairesEntete()
{
return array(
'ActSiren',
'ActPpPm',
'ActActif',
'ActPDetention',
'ActPVote',
'ActType',
'ActRS',
'ActPP',
'ActPPDateNaiss',
'ActPPLieuNaiss',
'ActPPNat',
'ActAdresse',
'ActIdLoc1Type',
'ActIdLoc1Num',
@ -1503,6 +1512,7 @@ function actionnairesEntete()
'ActIdLoc2Num',
'ActIdLoc3Type',
'ActIdLoc3Num',
'ActDateEffetLien',
'ActDate'
);
}
@ -1510,22 +1520,30 @@ function actionnairesEntete()
function actionnairesMultiple($siren, $nic)
{
require_once 'Metier/partenaires/classMLiens2.php';
$liensM = new MLiens2($siren, 'siren');
$liensM = new MLiens2($siren, 'siren', $db);
$result = $liensM->getActionnaires();
$tabData = array();
if (count($result)>0) {
foreach($result as $item) {
$formatElement = array();
$formatElement['ActSiren'] = $item->siren;
$formatElement['ActActif'] = $item->actif;
$formatElement['ActPDetention'] = $item->PDetention;
$formatElement['ActPVote'] = $item->PVote;
$formatElement['ActPpPm'] = $item->PpPm;
$formatElement['ActRS'] = $item->RS;
if ($item->PpPm == 'PP') {
$formatElement['ActPP'] = $item->civilite.' '.
$item->nom.' '.$item->prenom.
' ('.$item->nom_usage.') '.
'- Né le '.$item->naissance_date.' à '.$item->naissance_lieu;
$formatElement['ActPPDateNaiss'] = $item->naissance_date;
$formatElement['ActPPLieuNaiss'] = $item->naissance_lieu;
$formatElement['ActPPNat'] = $item->nat;
} else {
$formatElement['ActPP'] = '';
$formatElement['ActPPDateNaiss'] = '';
$formatElement['ActPPLieuNaiss'] = '';
$formatElement['ActPPNat'] = '';
}
$formatElement['ActAdresse'] = $item->adresse_num.' '.$item->adresse_btq.' '.
$item->adresse_codvoie.' '.$item->adresse_libvoie.' '.$item->adresse_comp.' '.
@ -1536,6 +1554,7 @@ function actionnairesMultiple($siren, $nic)
$formatElement['ActIdLoc2Num'] = $item->idLoc2Num;
$formatElement['ActIdLoc3Type'] = $item->idLoc3Type;
$formatElement['ActIdLoc3Num'] = $item->idLoc3Num;
$formatElement['ActDateEffetLien'] = $item->dateEffetLien;
if ($item->dateUpdate!='0000-00-00 00:00:00') {
$formatElement['ActDate'] = substr($item->dateUpdate,0,10);
} else {
@ -1546,8 +1565,6 @@ function actionnairesMultiple($siren, $nic)
}
}
print_r($tabData);
return $tabData;
}

View File

@ -30,22 +30,24 @@ class MLiens2
* @param string $type ref|siren
* @throws SoapFault
*/
public function __construct($id, $type = 'ref')
public function __construct($id, $type = 'ref', $db=null)
{
//Load configuration
if (Zend_Registry::isRegistered('config')) {
$c = Zend_Registry::get('config');
} else {
$c = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini');
}
//Connect to the database
try {
$this->db = Zend_Db::factory($c->profil->db->jo);
$this->db->getConnection();
} catch (Zend_Db_Adapter_Exception $e) {
throw new Exception($e->getMessage());
} catch (Zend_Exception $e) {
throw new Exception($e->getMessage());
if (null === $this->db) {
//Load configuration
if (Zend_Registry::isRegistered('config')) {
$c = Zend_Registry::get('config');
} else {
$c = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini');
}
//Connect to the database
try {
$this->db = Zend_Db::factory($c->profil->db->jo);
$this->db->getConnection();
} catch (Zend_Db_Adapter_Exception $e) {
throw new Exception($e->getMessage());
} catch (Zend_Exception $e) {
throw new Exception($e->getMessage());
}
}
if ( $type == 'siren' ) {