more on problem importing 1810-1819 data
In the _importCriminal method, this block of code:
if (isset($data->attributes()->id)) {
$xmlId = $data->attributes()->id;
} else {
$xmlId = null;
}
always returns null for $xmlId, as there are no attributes in any
instance of the criminal element in the data.
In the criminals table, there is no field named "xml_id", so any
reference to that field will throw an error.
There is one such reference in _importCriminal:
$new = array(
'surname' => $data->surname,
'given_name' => $data->given_names,
'age' => $data->age,
'gender_id_fk' => array_search(strtolower($data->gender),
$this->genderMap),
'xml_id' => $xmlId
);
$id = $this->tables['criminals']->insert($new);
and two references in one line in _syncCriminals:
$records =
Zend_Db_Table::getDefaultAdapter()->fetchPairs('SELECT criminal_id,
xml_id FROM criminals WHERE xml_id IS NOT NULL');
For the instance in _importCriminal, if I replace 'xml_id' with
'criminal_id' then the record is added to the criminals table, but of
course there is no field 'xml_id' so naturally no value for that field,
so I'm not sure if that's the desired behaviour.
For the instance in _syncCriminals, it makes no sense to simply replace
xml_id with criminal_id. I understand the logic of what syncCriminals is
supposed to do, but I don't see how that code can possibly not throw an
error. That line of code requires there be an xml_id field and a
criminal_id field in each record, but that's not the case.
Is there supposed to be an xml_id field in the criminals table? I can't
find any instance of that table which has such a field. Even if I did,
as far as I can figure, the value in that field would be NULL in every
instance. I have found no instances in the data file of a criminal element with an id attribute.
Wrote to Jamie again to see if any of this jogs his memory about the structure of the dev instance he was using.