This topic is locked
[SOLVED]

 import pk fail has misleading error message

3/19/2016 10:06:47 AM
PHPRunner General questions
jimbeam author

Hello,
I have a table with only one column named 'id'. The type is varchar and it is a primary key.
I am importing data with copy and paste. It works fine.
However, for the records that are violating the primary key constraint, I download the importLog.txt and I see the following error:




You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'where id='somestring'' at line 1

"somestring"
This 'somestring' is a record that already exists so my guess is that the error should be more meaningful like other cases (like fk constraints failure for example). Also, the database is MySQL so why the MariaDB text?
Kind regards,
Jim

Admin 3/20/2016

In regards to MariaDB error message - this error message is coming directly from the database meaning that your web host changed MySQL to MariaDB without telling you so. Feel free to check with them.
PHPRunner doesn't know anything about the error message itself. It checks if such a record exists first and then tries after update it or insert a new one. Any error happens on the way it will be posted to error log.
I guess you need to print exact SQL query on the page to see why it breaks.

jimbeam author 3/23/2016



In regards to MariaDB error message - this error message is coming directly from the database meaning that your web host changed MySQL to MariaDB without telling you so. Feel free to check with them.
PHPRunner doesn't know anything about the error message itself. It checks if such a record exists first and then tries after update it or insert a new one. Any error happens on the way it will be posted to error log.
I guess you need to print exact SQL query on the page to see why it breaks.


Thanks for replying,
I am running a local XAMPP package but after your reply, I noticed that the latest version came with MariaDB instead of MySQL rdbms that I was used to!.
I have never used this db but it seems that PHPRunner works with MariaDB as if it was MySQL, it doesn't complain.
However, when I run an insert SQL fragment directly on the database (using PHPMyAdmin), I get:

[color=#222222]
[font="Verdana"][color="#222222"]
[font="Verdana"][color="#222222"]



I guess the two messages are different because phprunner is trying to do an update instead of just an insert, right?

Also, I don't see mariaDb as supported. So, maybe I should switch to MySQL, right?
Thanks for the help
Cheers
Jim

Admin 3/23/2016

When importing PHPRunner checks if such record exists first. If record exists it tries to update it, if not it tries to insert it.
While there are some subtle differences between MySQL and MariaDB this error seems to be more generic. Personally I won't suggest using a field with values like ANDREOU a primary key. Use an integer field with auto increment as a primary key.

jimbeam author 3/24/2016



While there are some subtle differences between MySQL and MariaDB this error seems to be more generic. Personally I won't suggest using a field with values like ANDREOU a primary key. Use an integer field with auto increment as a primary key.


I agree with integers as PKs. I have "inherited" this database and it's a pain to change everything to INTs now...
Thanks again
Jim