Skip to main content
Topic: how can i see entire query ? (Read 1930 times) previous topic - next topic

how can i see entire query ?

Im getting this SQl error on a page i didnt change at all and im at a lost whats causing it. I need to see the entire query, this is not telling me the problem. I dont know what Index= Null means, i have no such field. Is there a way to see it as its passed to mysql ?

"SQLSTATE[42000]: Syntax error or access violation: 1064 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 'Index = NULL ORDER BY g DESC, h DESC LIMIT 1000 OFFSET 0' at line 1"


Thanks for any help.


Re: how can i see entire query ?

Reply #2
It is the List Page of a table in classic 2.59 . It was originally created with 2.5.1.
I used the duplicate page feature to make another one based on this one which was working and then after publish it no longer worked.

Re: how can i see entire query ?

Reply #3
Inside the ListPageController you can call
Code: [Select]
echo $db->getLastQuery();
  After the
Code: [Select]
$db->get() 
command.

Re: how can i see entire query ?

Reply #4
I did this
$records = $db->get($tablename, $limit, $fields);
      echo $db->getLastQuery();

But doesnt show anything for me besides the standard error.

Re: how can i see entire query ?

Reply #5
I did this
$records = $db->get($tablename, $limit, $fields);
      echo $db->getLastQuery();

But doesnt show anything for me besides the standard error.

try to add Try Catch and add echo $db->getLastQuery in Catch. The error in $records line is not allowing the code to move on to the next line.

try {
$records = $db->get($tablename, $limit, $fields);
}
catch(\Exception $e) {
echo $db->getLastQuery();
}

Re: how can i see entire query ?

Reply #6
Thanks that worked!

Now the query displayed is

SELECT SQL_CALC_FOUND_ROWS id, b, pseudo, f, g, h, altersklassen.id AS altersklassen_id, altersklassen.Klasse, kategorien.id AS kategorien_id, kategorien.kategorie FROM meisterschaft WHERE e REGEXP '[a-zA-Z]' AND Index = NULL ORDER BY g DESC, h DESC LIMIT 10 OFFSET 0

and mysql sais syntax error near Index=Null
Which i dont understand cause i never had a field named Index in there...  ::)