PHP-MySQLi-Database-Class icon indicating copy to clipboard operation
PHP-MySQLi-Database-Class copied to clipboard

Fix rawAddPrefix() to add prefix to all tables in raw query

Open alikm6 opened this issue 1 year ago • 0 comments

In the rawAddPrefix function, the prefix is added only to the first table in the query, if we have join and ... in the query, the prefix must be added to the names of all tables.

For example, query

select t1.id as post_id, t2.id as bot_id from posts as t1 inner join bots as t2 on t1.bot_id = t2.id

is converted to

select t1.id as post_id, t2.id as bot_id from tbl_posts as t1 inner join bots as t2 on t1.bot_id = t2.id

when it should be converted to

select t1.id as post_id, t2.id as bot_id from tbl_posts as t1 inner join tbl_bots as t2 on t1.bot_id = t2.id

This issue is resolved in this change.

alikm6 avatar Jun 28 '24 12:06 alikm6