I'm using PHP for some simple shell scripting to convert existing data into SQLite tables on my local machine. However, when I run the scripts on the command line, I do not get errors even when the INSERT function clearly fails (i.e. the records aren't in the table when it's through). Is there an obvious solution to this?
The code below is a simplified version of what I'm using (which has more subloops, etc. which make it difficult to track down what exactly isn't being inserted in the tables). For example, if person's name has a newline char in it, it doesn't get inserted, but I have no error message to determine the problem. Also, I initially forgot to use the single quotes around the emp_name text field, and also did not get an error on the command line.
$db = new PDO('sqlite:mydatabase.sqlite');
$db->exec("CREATE TABLE employee_data (emp_id INTEGER, emp_name TEXT);");
$db->beginTransaction();
foreach($people_data as $person) {
$db->exec("INSERT INTO employee_data VALUES ('{$person->emp_id}', '{$person->emp_name}');");
}
$db->commit();
$db = NULL;
Thanks! Bryan