Import cvs file

HI! I have a problem with create import filter. With table anagrafica,
in class anagrafica I have create this methods copy from other topic in this forum:
When I try to import this file cvs:
I have some question about import, the first field is `idanagrafica` that is auto_increment, I have to import it too? Is possible to skip some field in import? Like Blob fields as foto? Whe import field that using a valuelist as vocabulary I have to import code value o description: Ex for field [sangue] I have valuelist
[Sangue]
0RH+ = 0 RH positivo
0RH- = 0 RH negativo
A = Gruppo A
B = Gruppo B
AB = Gruppo AB
In cvs file I have to use 0RH+,0RH-,A,B or 0 RH positivo,0 RH negativo,Gruppo A...?
Thanks for help, and Sorry for my bad English!!
P.S. Happy Easter!!
- Code: Select all
CREATE TABLE `anagrafica` (
`idanagrafica` int(10) unsigned NOT NULL auto_increment,
`arte` varchar(3) NOT NULL default '',
`nome` varchar(30) NOT NULL default '',
`cognome` varchar(30) NOT NULL default '',
`sesso` char(1) NOT NULL default '',
`cf` varchar(15) default NULL,
`domicilio` varchar(60) NOT NULL default '',
`email` varchar(35) default NULL,
`telefono` varchar(15) default NULL,
`datanascita` date NOT NULL default '0000-00-00',
`luogonascita` varchar(30) NOT NULL default '',
`statocivile` enum('Single','Sposato','Separato','Divorziato') NOT NULL default 'Single',
`occupazione` varchar(40) default NULL,
`altezza` int(10) unsigned default NULL,
`peso` int(10) unsigned default NULL,
`sangue` varchar(8) default NULL,
`cmtipo` varchar(10) default NULL,
`cmscadenza` date default NULL,
`tesscadenza` date default NULL,
`assscadenza` date default NULL,
`matricola` varchar(20) default NULL,
`dataiscrizione` date default NULL,
`titolo` varchar(20) default NULL,
`cintura` varchar(10) NOT NULL default '',
`foto` blob NOT NULL,
`foto_mimetype` varchar(30) default 'image/jpeg',
PRIMARY KEY (`idanagrafica`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=24 ;
in class anagrafica I have create this methods copy from other topic in this forum:
- Code: Select all
function __import__csv(&$data, $defaultValues=array()){
// build an array of Dataface_Record objects that are to be inserted based
// on the CSV file data.
$records = array();
// first split the CSV file into an array of rows.
$rows = explode("\n", $data);
foreach ( $rows as $row ){
if ($rowsetValues($defaultValues);
// Now we add the values from the CSV file.
$record->setValues(
array(
'idanagrafica'=>$idanagrafica,
'arte'=>$arte,
'nome'=>$nome,
'cognome'=>$cognome,
'sesso'=>$sesso,
'cf'=>$cf,
'domicilio'=>$domicilio,
'email'=>$email,
'telefono'=>$telefono,
'datanascita'=>$datanascita,
'luogonascita'=>$luogonascita,
'statocivile'=>$statocivile,
'occupazione'=>$occupazione,
'altezza'=>$altezza,
'peso'=>$peso,
'sangue'=>$sangue,
'cmtipo'=>$cmtipo,
'cmscadenza'=>$cmscadenza,
'tesscadenza'=>$tesscadenza,
'assscadenza'=>$assscadenza,
'matricola'=>$matricola,
'dataiscrizione'=>$dataiscrizione,
'titolo'=>$titolo,
'cintura'=>$cintura,
'foto'=>$foto,
'foto_mimetype'=>$foto_mimetype
)
);
// Let us check first if the row has some value. If it is empty don't insert.
if (($row[$nome]) == '') {
unset($record);}
else {
// Since there is value, now add the record to the output array.
$records[] = $record;
unset($record);
}
}
}
// Now we return the array of records to be imported.
return $records;
unset($ws);
}
When I try to import this file cvs:
- 33,"HRD","pippo ","franco","Maschio","sdfsdfsd","Roma Via ciccio 40","fantomasdm@kkkk.it",342342432,22/04/75,"Roma","Single","Developer",178,80,"0RH-","NRM",10/07/08,10/07/08,10/07/08,"T0104",10/07/08,"YDJ","bianca","/gest/index.php?-action=getBlob&-table=anagrafica&-field=foto&-index=0&idanagrafica=30","image/png"
- row:33,"HRD","pippo ","franco","Maschio","sdfsdfsd","Roma Via ciccio 40","fantomasdm@kkkk.it",342342432,22/04/75,"Roma","Single","Developer",178,80,"0RH-","NRM",10/07/08,10/07/08,10/07/08,"T0104",10/07/08,"YDJ","bianca","/gest/index.php?-action=getBlob&-table=anagrafica&-field=foto&-index=0&idanagrafica=30","image/png"
Fatal error: Cannot use object of type PEAR_Error as array in /var/www/vhosts/lotta.genesisliceo.it/httpdocs/dataface-0.7.1/Dataface/Table.php on line 2486
I have some question about import, the first field is `idanagrafica` that is auto_increment, I have to import it too? Is possible to skip some field in import? Like Blob fields as foto? Whe import field that using a valuelist as vocabulary I have to import code value o description: Ex for field [sangue] I have valuelist
[Sangue]
0RH+ = 0 RH positivo
0RH- = 0 RH negativo
A = Gruppo A
B = Gruppo B
AB = Gruppo AB
In cvs file I have to use 0RH+,0RH-,A,B or 0 RH positivo,0 RH negativo,Gruppo A...?
Thanks for help, and Sorry for my bad English!!
P.S. Happy Easter!!