3
Quote:
Mithrandir wrote:
Yes, I have a code snippet supporting this:
in class/database/sqlutility.php, replace prefixQuery() function with this:
/**
* add a prefix.'_' to all tablenames in a query
*
* @param string $query valid SQL query string
* @param string $prefix prefix to add to all table names
* @return mixed FALSE on failure
*/
function prefixQuery($query, $prefix)
{
$pattern = "/^(INSERT INTO|CREATE TABLE|ALTER TABLE|UPDATE)(s)+([`]?)([^`s]+)\3(s)+/siU";
$pattern2 = "/^(DROP TABLE)(s)+([`]?)([^`s]+)\3(s)?$/siU";
$pattern3 = "/(REFERENCES)(s)+([`]?)([^`s]+)\3/iU";
if (preg_match($pattern, $query, $matches) || preg_match($pattern2, $query, $matches)) {
$replace = "\1 ".$prefix."_\4\5";
$matches[0] = preg_replace($pattern, $replace, $query);
$matches[0] = preg_replace($pattern3, $replace, $matches[0]);
return $matches;
}
return false;
}
Ahhh, I've been searching around a bit for that info Mithrandir :)
But on that note, how do we make sure uninstall of the same module won't fail due to those very same 'dependancies' in the tables?
I've had to manually drop those tables in one shot as the uninstaller fails to drop single tables that are being referenced:
mysql> drop table xoops_table1,xoops_table2,xoops_table3;
Cheers! :)