How to find the sql error from the log MODX?

Constantly comes an error about SQL syntax. I can not understand where to look. Tell me how to catch it?
Tried to search through links on the website and doing the actions in the admin area. Never found. Error in production, but in the copy it is impossible to repeat.

[2019-12-19 18:22:06] (ERROR @ /home/site.ru/core/xpdo/om/xpdoobject.class.php : 240) Error 42000 executing statement:
Array
(
[0] => 42000
[1] => 1064
[2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') DESC' at line 1
)


upd. Who encounter such a situation, you can correct this string in xpdoobject.class.php and add the output of the full sql of the query.
$xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Error' . $criteria->stmt->errorCode() . "executing statement: \n" . print_r($errorInfo, true) . 'SQL' . $criteria->toSQL());
April 3rd 20 at 18:44
2 answers
April 3rd 20 at 18:46
Solution
Open the file /home/site.ru/core/xpdo/om/xpdoobject.class.php line 240
and see that there is a query that gives an error.
although this is navreno shny PDO class? hmm... well at least to see what object/method is called
and in the code look for calling this place.

PS: copy from production database! then maybe most likely will have to repeat.
And there's a full copy.
She is invoked here
if (!$criteria->stmt->execute()) {
$xpdo->queryTime += microtime(true) - $tstart;
$xpdo->executedQueries++;
$xpdo->log(xPDO::LOG_LEVEL_ERROR, "Error" . $criteria->stmt->errorCode() . "executing statement: \n" . print_r($criteria->stmt->errorInfo(), true));
}

That is, when a sql error and will not work properly. But it is so clear. I would have to find in what place of this error. - noemie_Kub71 commented on April 3rd 20 at 18:49
@noemie_Kub71so, what is the SQL in this place is done?? - Matilda commented on April 3rd 20 at 18:52
$criteria->stmt->execute()
This line checks whether it is possible to execute sql with parameters $criteria
But the point is that this handler $xpdo, and through him to all requests pass. This part of the work of modx. - noemie_Kub71 commented on April 3rd 20 at 18:55
@noemie_Kub71, well, then maybe it is worth adding at this point the output to a log SQL Query?
moreover, the output in the log put in front if
it is clear that there will be a bunch of SQL queries in the log, but will be immediately after the mistake and error.
accordingly take the request before the error from the log. - Matilda commented on April 3rd 20 at 18:58
@Matilda, returned to this issue. Thanks for the idea, helped. Brought incorrect sql and found the row with the error. - noemie_Kub71 commented on April 3rd 20 at 19:01
April 3rd 20 at 18:48
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') DESC' at line 1

it is.
Thanks cap) So where it to find? I have such strings with 1000 there in the code. - noemie_Kub71 commented on April 3rd 20 at 18:51

Find more questions by tags MODXSQL