Ajout mode verbeux

This commit is contained in:
Michael RICOIS 2015-01-13 09:48:02 +00:00
parent b189137b3f
commit 1f2e47ba42

View File

@ -28,7 +28,8 @@ try {
array( array(
'help|?' => "Aide.", 'help|?' => "Aide.",
'id=s' => "Identifiant du traitement", 'id=s' => "Identifiant du traitement",
'file=s' => "Identifiant pour les traitements par fichier" 'file=s' => "Identifiant pour les traitements par fichier",
'verbose' => "Mode verbeux",
) )
); );
$opts->parse(); $opts->parse();
@ -45,15 +46,6 @@ if(isset($opts->help) || !isset($opts->id) && !isset($opts->file) )
$config = new Zend_Config($application->getOptions()); $config = new Zend_Config($application->getOptions());
//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);
//Définition bdd //Définition bdd
try { try {
$db = Zend_Db::factory($config->profil->db->metier); $db = Zend_Db::factory($config->profil->db->metier);
@ -215,10 +207,12 @@ if ($opts->id)
$row = 1; $row = 1;
//Date de debut de traitement. //Date de debut de traitement.
$dateStart = date('YmdHms'); $dateStart = date('YmdHis');
foreach ($identifiants as $siret) foreach ($identifiants as $siret)
{ {
$sql = $db->select()->from('jo.etablissements_act', $columns); if ($opts->verbose) echo "Line $row.\n";
$sql = $db->select()->from('etablissements_act', $columns, 'jo');
$sql->where("siren='".substr($siret,0,9)."' AND nic='".substr($siret,9,5)."'"); $sql->where("siren='".substr($siret,0,9)."' AND nic='".substr($siret,9,5)."'");
if (count($joins)) if (count($joins))
{ {
@ -231,7 +225,7 @@ foreach ($identifiants as $siret)
try { try {
$result = $db->fetchRow($sql); $result = $db->fetchRow($sql);
} catch(Exception $e) { } catch(Exception $e) {
echo $sql; echo $sql."\n";
} }
$tabData = $result->toArray(); $tabData = $result->toArray();
@ -242,10 +236,11 @@ foreach ($identifiants as $siret)
//Add static values //Add static values
if ( array_key_exists($key, $fields) ) { if ( array_key_exists($key, $fields) ) {
if ( array_key_exists('values', $fields[$key]) ) { if ( array_key_exists('values', $fields[$key]) ) {
$values = $fields[$key]['values']; $valuesRef = $fields[$key]['values'];
$value = $tabData[$key];
//Remplace value if exist //Remplace value if exist
if ( in_array($tabData[$key], $values) ) { if ( array_key_exists($value, $valuesRef) ) {
$tabData[$key] = $values[$tabData[$key]]; $tabData[$key] = $valuesRef[$tabData[$key]];
} }
} }
} }