50 lines
1.7 KiB
PHP
50 lines
1.7 KiB
PHP
#!/usr/bin/php -c/var/www/batch/config/php_batch_sd.ini
|
|
<?php
|
|
include_once('/var/www/framework/common/mysql.php');
|
|
|
|
define ('TODAY', substr(DATETIME,0,8));
|
|
define ('TODAY_FORMAT', substr(DATETIME,0,4).'-'.substr(DATETIME,4,2).'-'.substr(DATETIME,6,2));
|
|
define ('NOW_FORMAT', substr(DATETIME,8,2).':'.substr(DATETIME,10,2).':'.substr(DATETIME,12,2));
|
|
|
|
$iDb=new WDB('insee');
|
|
|
|
$sql="CREATE TABLE IF NOT EXISTS bascule (
|
|
insSIREN varchar(9) NOT NULL default '',
|
|
insNIC varchar(5) NOT NULL default '',
|
|
insAPEN5 varchar(5) default NULL,
|
|
insAPEN4 varchar(4) default NULL,
|
|
insDEPCOM varchar(5) default NULL,
|
|
insSIEGE tinyint(1) NOT NULL default '0',
|
|
insAPET5 varchar(5) default NULL,
|
|
insAPET4 varchar(4) default NULL ) TYPE=MyISAM COMMENT='Bascule INSEE';";
|
|
$ret=$iDb->query($sql, true);
|
|
$nomFichier='/mnt/samba/partage/infos fournisseurs/insee/naf/BASCULE.TXT';
|
|
$fp=fopen($nomFichier,"r");
|
|
while (!feof($fp))
|
|
{
|
|
$nbLignes++;
|
|
|
|
$a = fgets($fp, 4096);
|
|
$insSIREN =substr($a, 0, 9);
|
|
$insNIC =substr($a, 9, 5);
|
|
$insNAFen5 =substr($a, 14, 5);
|
|
$insNAFen4 =substr($a, 19, 4);
|
|
$insDEPCOM =substr($a, 23, 5);
|
|
$insSIEGE =substr($a, 28, 1);
|
|
$insNAFet5 =substr($a, 29, 5);
|
|
$insNAFet4 =substr($a, 34, 4);
|
|
|
|
$tabDataToInsert=array( 'insSIREN' => $insSIREN,
|
|
'insNIC' => $insNIC,
|
|
'insAPEN5' => $insNAFen5,
|
|
'insAPEN4' => $insNAFen4,
|
|
'insDEPCOM'=> $insDEPCOM,
|
|
'insSIEGE' => $insSIEGE,
|
|
'insAPET5' => $insNAFet5,
|
|
'insAPET4' => $insNAFet4,
|
|
);
|
|
$iDb->insert('bascule', $tabDataToInsert);
|
|
}
|
|
|
|
?>
|