网络营销电子商务研究中心

网络营销电子商务研究中心 (https://www.0058.net/index.php)
-   Web Directory (https://www.0058.net/forumdisplay.php?f=60)
-   -   Category description length (varchar 255) can increase? (https://www.0058.net/showthread.php?t=2711)

topvip 2007-08-17 02:55 AM

Category description length (varchar 255) can increase?
 
Here is the code:

Quote:

<?php
/************************************************
* INSTALL:

* Place this in your main folder, after you

* run it, please rename it or remove it from

* the site so no one else could use it on your

* database.

*

************************************************/





// Include the initialization info

include('init.php');



// Add a new field

$sql = "ALTER TABLE {$tables['category']['name']} ADD DESC_LONG TEXT NULL AFTER DESCRIPTION";



// If that completed alright, then lets continue on, otherwise DIE DIE DIE!!

if (!$db->Execute($sql))

{

die (mysql_error());

}



// Now, lets grab the DESCRIPTIONS, and input them into the new field

$sql = "SELECT ID, DESCRIPTION FROM {$tables['category']['name']}";



// Pull the results

$data = $db->GetAll($sql);



// Now lets do the ole switch arooo

foreach($data as $row)

{

// Update SQL, it now switches the two DESCRIPTION's around

$db->Execute("UPDATE {$tables['category']['name']} SET DESC_LONG = '" . $row['DESCRIPTION'] . "' WHERE ID = {$row['ID']}");

}



// Now, for the final step we'll rename DESCRIPTION to DESCRIPTION_OLD, and DESC_LONG to DESCRIPTION

$db->Execute("ALTER TABLE {$tables['category']['name']} CHANGE DESCRIPTION DESCRIPTION_OLD VARCHAR( 255 ) NULL DEFAULT NULL") or die (mysql_error());



$db->Execute("ALTER TABLE {$tables['category']['name']} CHANGE DESC_LONG DESCRIPTION TEXT NULL DEFAULT NULL") or die (mysql_error());



echo "All went fine... I guess ; )";



?>
save as description.php, and run it with ie. and deleted it.


All times are GMT +8. The time now is 10:49 PM.

Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.