SHOW TABLE STATUS LIKE '{$config['TABLE_PREFIX']}%'
This query does not escape special characters, like the underscore.
I have both an ubbtest_ and ubbt_, and if I do a database info on the ubbt_ setup, I also get all ubbtest_ tables. Escaping the underscore with an \ would do the trick.
#195436 - 08/27/0701:04 PMRe: [7.2] database info query does not escape special characters
[Re: blaaskaak]
Sirdude
Registered: 04/19/07
Posts: 2041
Loc: SoCal, USA
using LIKE is not the way to go either, because there is no guarantee of _ after each prefix... yes, i always DO use _, but it's not forced upon the admin at setup..
assume there are two db's 'ubbt' and 'ubbtest' (no underscore)..
the like will match both too if the query did "like ubbt%"
best way is to do an equality check on the actual prefix including the length..
ie:
Code:
SHOW TABLE STATUS WHERE LEFT(Name,LENGTH('{$config['TABLE_PREFIX']}')) = '{$config['TABLE_PREFIX']}'
this should also handle the _ problem you had.. assumes latin1 charset (you may have different)
2c
_________________________ A taxpayer voting for Obama is like a chicken voting for Colonel Sanders.
using LIKE is not the way to go either, because there is no guarantee of _ after each prefix... yes, i always DO use _, but it's not forced upon the admin at setup..
I know it's not guaranteed. But doesn't escaping the _ with a \ make sure you test for ubbt_ instead of ubbt?. Don't see why like can't do the trick we want.
Originally Posted By: MrDude
this should also handle the _ problem you had..
well, it definatly saves adding code to escape the _.
#195438 - 08/27/0701:15 PMRe: [7.2] database info query does not escape special characters
[Re: blaaskaak]
Sirdude
Registered: 04/19/07
Posts: 2041
Loc: SoCal, USA
sure it will, if we assume _ is forced.. i will cede that point.
now some poor bastard is gonna leave an _ out and he won't get what he expects..
it only affects that one line, so i was suggesting how to handle all cases..
i would be interested if that query handles the _ for you though.. without escaping the _ .. because i have the exact same setup .. (ubbt_ and ubbtmuhaha_) and it works ...
so all i can see is that we have two diff charsets for the db? or diff version of mysql ? (i have latin1, mysql5) and DON'T have to escape the _ ..
hehe postscript.. a user can still screw themselves if the WANT.. but i wouldn't worry too much about it either.. ie: ubbt_ and ubbt_new_
so we are splitting hairs to an extent, but i like to go 'geek' every so often
_________________________ A taxpayer voting for Obama is like a chicken voting for Colonel Sanders.