php - How to generate basic CLI error message for failed sqlite insert? -


I have been using PHP for some simple shell scripting to convert existing data to SQLite tables on my local machine I am However, even when I run the script on the command line, I still do not make a mistake whenever the INSERT function clearly fails (i.e. the record is not valid when it is through). Is there a clear solution?

The code below is a simplified version of what I am using (which is more number of sublops, etc.) which make it difficult to track down what is not actually being included in the tables For example, if the person's name has a new line in it, then it is not included, but I have no error message to determine the problem. Besides, I initially forgot to use single quotation marks around the emp_name text field, and did not get the error even on the command line.

  $ db = new PDO ('sqlite: mydatabase.sqlite'); $ Db- & gt; Exec ("Creating table worker_data (emp_id INTEGER, emp_name text);"); $ Db- & gt; BeginTransaction (); Foreach ($ person_data $ person) {$ db- & gt; ("{$ Person-> emp_id} ',' {$ person- & gt; emp_name} ');););} $ db- & gt; commit (); $ Thank you for using PDO!  

The PDO is silent by default. Brian

Using

, which can be stopped when you mess up something if you enable the warning mode, then also make sure that you can display the warnings that others All It can be done by the orders posted by people.

If you want to do it manually, then errorCode and errorInfo methods Which you can check after each query, which I have been used on the above error mode page.

Comments