I’ve made a script that imports stuff from one database and puts it into another; the problem is that it breaks with the message:
PDOException: in hcap_import_do() (line 215 of /mnt/hgfs/docroot/hcapdrupal/site_drupal/public_html/sites/all/modules/custom/hcap/hcap.module).
The code that the following one:
db_insert('hcap_candidates')->fields(array(
'id' => $e['old_id'],
'pic' => $e['logo'],
'placed' => $e['placed'],
'title' => $e['title'],
'name' => $e['name'],
'interim' => $e['interim'],
'permanent' => $e['permanent'],
'birth' => $e['birth'],
'marital_status' => $e['marital'],
'adress' => $e['address'],
'city' => $e['city'],
'postal' => $e['postal'],
'phone_home' => $e['phone_home'],
'phone_work' => $e['phone_work'],
'phone_mobile' => $e['phone_mobile'],
'email1' => $e['email1'],
'email2' => $e['email2'],
'reg_by' => $e['reg_by'],
'cand_head' => $e['cand_head'],
'cand_body' => $e['cand_body'],
'prominent' => $e['prominent'],
'broadcast' => $e['broadcast'],
'cv' => $e['cv'],
'old_id' => $e['old_id']
))->execute(); // This is line 215.
Does anyone have any clue as to what is wrong?
You can use a “try … catch” block to learn more about the error. I’d need more surrounding code and the table structure to understand why the query is failing, but the syntax appears to be correct.
In case you aren’t sure, here is what a “try … catch” block looks like in PHP:
There is probably a simple issue with your query (no table called
hcap_candidates, no field in that table calledmarital_status, etc.). The exception message should tell you all you need to know.BTW, print_r is only one quick-and-dirty way to see the output in a browser. You can also use watchdog, drupal_set_message…