1
Choozo
Re: (Theme creation) Which Software for beginners?
  • 2005/11/25 6:57

  • Choozo

  • Just popping in

  • Posts: 3

  • Since: 2005/11/13


Quote:

tipug wrote:

ps. please dont say to look through the forums and FAQs, because im really busy!!!

PLEASE HEEELLPPPPP!!!! this is urgent.

Yeah, I can really see people here tripping over themselves to help out after a comment like that



2
Choozo
Re: FOREIGN KEY Refernces ..
  • 2005/11/15 17:37

  • Choozo

  • Just popping in

  • Posts: 3

  • Since: 2005/11/13


Oh, never mind. I just found out how to take advantage of the '$modversion['tables'][n] = "tablename"' in the xoops_version.php file!

Just have to be real careful when setting the order of tables there. Tables are dropped according to that order, so make sure you don't drop a table referenced from another before that 'another' table is dropped.

Cheers



3
Choozo
Re: FOREIGN KEY Refernces ..
  • 2005/11/14 20:31

  • Choozo

  • Just popping in

  • Posts: 3

  • Since: 2005/11/13


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:
mysqldrop table xoops_table1,xoops_table2,xoops_table3;


Cheers! :)




TopTop



Login

Who's Online

114 user(s) are online (85 user(s) are browsing Support Forums)


Members: 0


Guests: 114


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits