Author Topic: password plugin sql update multiple tables  (Read 338 times)

Offline Juppers

  • Newbie
  • *
  • Posts: 2
password plugin sql update multiple tables
« on: March 09, 2024, 11:22:28 AM »
I am trying to update multiple tables when someone changes their password. Because the second table is external via the connect engine in mariadb, I can't use a trigger to update it.
I have been trying to update the sql query to handle both updates, but it fails even thought the query is valid. Yes, I have disabled password encryption for the moment for troubleshooting.

Is there an easier way to have the password plugin run multiple queries or dealing with multiple dsn's?

Code: [Select]
$config['password_query'] = "UPDATE mailbox SET password=%P,plain_password=%p,passwordlastchange=NOW() WHERE username=%u;update email_data set password =%p where emailaddr=%u";

Code: [Select]
Mar  9 10:40:15 mail roundcube: <0f5vgmc9> DB Error: [1064] You have an error in your SQL syntax; check the manual that correspo
nds to your MariaDB server version for the right syntax to use near 'update email_data set password ='etstetst' where emailaddr='sup
ertest@domain...' at line 1 (SQL Query: UPDATE mailbox SET password='{PLAIN}etstetst',plain_password='etstetst',passwordlastchange=
NOW() WHERE username='supertest@domain.com' ;update email_data set password ='etstetst' where emailaddr='supertest@domain.com') in
 /opt/www/roundcubemail-1.6.5/program/lib/Roundcube/rcube_db.php on line 577 (POST /mail/?_task=settings&_action=plugin.password-sav
e)

Offline JohnDoh

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2,856
Re: password plugin sql update multiple tables
« Reply #1 on: March 10, 2024, 03:52:24 AM »
I'm not sure if you can put multiple statements in a single query() call. How would the response be handled? I think a better way is to use an SQL function. You can see some examples in the password plugin readme. In the function you can execute multiple statements.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and moreā€¦

Offline Juppers

  • Newbie
  • *
  • Posts: 2
Re: password plugin sql update multiple tables
« Reply #2 on: March 10, 2024, 10:04:00 AM »
Unfortunately the connect engine doesn't allow stored procedures or functions either.

I guess I will need to just script the changes and use the expect or some other cli based driver. Thanks.