Third Party Contributions > API Based Plugins

password plugin sql update multiple tables


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: ---$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";

--- End code ---

--- Code: ---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='' ;update email_data set password ='etstetst' where emailaddr='') in
 /opt/www/roundcubemail-1.6.5/program/lib/Roundcube/rcube_db.php on line 577 (POST /mail/?_task=settings&_action=plugin.password-sav
--- End code ---

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.

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.


[0] Message Index

Go to full version