odea/batch/setMinMax.php

23 lines
956 B
PHP
Raw Normal View History

2012-02-20 14:08:13 +00:00
<?php
$db_230 = mysql_connect('192.168.78.230', 'sphinx', 'indexer');
mysql_select_db('jo', $db_230);
$localhost = mysql_connect('127.0.0.1', 'root', '');
mysql_select_db('sdciblage', $localhost);
$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'
);
mysql_query('TRUNCATE TABLE minmax', $localhost) or die ('Impossible de vider la table minmax');
foreach($keys as $key) {
$sql = 'SELECT MIN('.$key.') AS min, MAX('.$key.') AS max FROM etablissements_act';
$query = mysql_query($sql, $db_230);
$result = mysql_fetch_assoc($query);
$sql = 'INSERT INTO minMax VALUES ("'.$key.'", '.$result['min'].', '.$result['max'].')';
mysql_query($sql, $localhost) or die(mysql_error($localhost));
print($key.'-> min:'.$result['min'].' max:'.$result['max']."\n");
}
print('Terminé');