ifsnop / mysqldump-php

PHP version of mysqldump cli that comes with MySQL
https://github.com/ifsnop/mysqldump-php
GNU General Public License v3.0
1.25k stars 300 forks source link

Add debug / verbose mode with dumping all generated SQL queries #228

Open MurzNN opened 3 years ago

MurzNN commented 3 years ago

Will be good to add debug or verbose mode, that will dump all generated SQL queries to console before executing. Very often dump process generates the SQL errors, but it's too hard to understand in which step it happens.

For example, on my dump proccess I see only this output:

mysqldump-php error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause'

And can't figure out in which exact table this happens.

MurzNN commented 3 years ago

Something like this https://github.com/ifsnop/mysqldump-php/pull/229

ifsnop commented 3 years ago

Will be good to add debug or verbose mode, that will dump all generated SQL queries to console before executing. Very often dump process generates the SQL errors, but it's too hard to understand in which step it happens.

For example, on my dump proccess I see only this output:

mysqldump-php error: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause'

And can't figure out in which exact table this happens.

I think this is a great idea. Reviewing your patch, I would suggest to use the PHP_EOL instead of '\n' (when used in windows, PHP_EOL will get translated to '\r\n' automatically, and add the new option to the documentation in the README file.

Also, sql statements should be written in every call to "dbhandler->query". There are 19 calls in the source code, and you only inserted code in one of the (in the listValues function). What do you think? Do you only need that call to be verbose?

-- -- Use of a keyboard or mouse may be linked to serious injuries or disorders. diego dot torres at gmail dot com - Madrid / Spain

MurzNN commented 3 years ago

Sorry for delay, I've replaced \n to PHP_EOL now. About other calls - there are quite a lot of them, so better to move verbose output to wrapper function, I've pushed this change to my PR - please review.