OpenSIPS / opensips-cp

A Web Control Panel Application for the OpenSIPS, which is intended for both system and user provisioning. It features more than 18 tools, covering important functionalities (MI,statistics) and modules (acc,siptrace,drouting,dialplan) of OpenSIPS.
GNU General Public License v2.0
117 stars 79 forks source link

fix backticks breaking query #293

Open greenbea opened 5 months ago

greenbea commented 5 months ago

The backtick works fine for mysql but breaks for postgres. Mysql supports double quotes too for identifiers .https://dev.mysql.com/doc/refman/8.0/en/sql-mode.html#sqlmode_ansi_quotes.

greenbea commented 4 months ago

You have to set the sql_mode. Try

 new PDO($dsn, "opensips", "opensipsrw", array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET sql_mode="ANSI_QUOTES"'));
liviuchircu commented 4 months ago

Hi @greenbea! I just pushed a new branch for working on this issue (bugfix/fix-dashboard-postgres), with a preliminary fix, inspired by the discussion so far. Could you please check that commit / approach and see if it fixes the dashboard on your Postgres setup?

In short, there are lots of PDO objects being created from various db.inc.php files, and I've tried to only create the "dashboard" connection with ANSI_QUOTES SQL mode, so we don't break other code by "fixing" things here.