#!/usr/bin/php "Aide.", 'cron' => "Mode automatique", 'manuel' => "Mode manuel", ) ); $opts->parse(); } catch (Zend_Console_Getopt_Exception $e) { echo $e->getUsageMessage(); exit; } //Usage if(isset($opts->help)) { echo $opts->getUsageMessage(); exit; } $dbConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/configuration.ini', 'databases'); try { $db = Zend_Db::factory($dbConfig->db); } catch ( Exception $e ) { exit ( $e->getMessage() ); } //Définition bdd metier try { $dbMetier = Zend_Db::factory($dbConfig->jo); } catch ( Exception $e ) { exit ( $e->getMessage() ); } $keys = array( 'nbActio','nbPart', 'teff_entrep', 'teff_etab', 'nbEtab', 'eff_entrep', 'eff_etab', 'capital', 'bilEE', 'bilFL', 'bilFK', 'bilFR', 'bilGF', 'bilGP', 'bilGW', 'bilHD', 'bilHH', 'bilHL', 'bilHM', 'bilHN', 'bilYP' ); $sql = 'TRUNCATE TABLE minmax'; if ( !$db->query($sql) ) { die ('Impossible de vider la table minmax'); } foreach($keys as $key) { //Lecture $sql = 'SELECT MIN('.$key.') AS min, MAX('.$key.') AS max FROM etablissements_act'; $dbMetier->setFetchMode(Zend_Db::FETCH_ASSOC); $result = $stmt->fetchAll($sql); //Insertion $data = array( 'key' => $key, 'min' => $result['min'], 'max' => $result['max'], ); $db->insert('minmax', $data); if ($opts->manuel) print($key.'-> min:'.$result['min'].' max:'.$result['max']."\n"); } if ($opts->manuel) print('Terminé');