dsoares / roundcube-lastlogin

Roundcube plugin to save and show user login information and login history.
GNU General Public License v3.0
16 stars 12 forks source link

forgot other db provider: DB Error: [7] ERROR: syntax error at or near "`" with solution #10

Closed mckaygerhard closed 8 years ago

mckaygerhard commented 8 years ago

some debug enablin in roundcube and got that:

[22-Jun-2016 14:13:25 -0400]: DB Error: [7] ERROR:  syntax error at or near "`"
LÍNEA 1: SELECT if(real_ip!='',real_ip,ip) AS `from`, hostname, EXTRA...
                                              ^ (SQL Query: SELECT if(real_ip!='',real_ip,ip) AS `from`, hostname, EXTRACT (EPOCH FROM timestamp) AS `date`, geoloc AS `geo` FROM userlogins WHERE user_id = '89' ORDER BY id DESC LIMIT 20) in program/lib/Roundcube/rcube_db.php on line 467 (GET /elcorreo/?_task=settings)

this is due are using the "" sintax used in mysql, u cannot use the mysql short sintax must use no "" for object names and for string the normal "'" single cuotes

later then got error due if" are not a sql standar function ERROR: function if(boolean, character varying, character varying) does not exist LINE 1: SELECT if(real_ip!='',real_ip,ip) AS "from", hostname, EXTRA...

about names using alias, "from" its a reserved keyword, so better do not use it,

so i'll provide a query in few hours to solve it and able to use either sqlite, postges and mysql, du i made some dirty hack and works with odbc and sqlite too!

dsoares commented 8 years ago

See https://github.com/dsoares/Roundcube-Plugin-Lastlogin/pull/11#issuecomment-228069363.