benwalsh Posted July 29, 2006 Share Posted July 29, 2006 I have the some text to remove from all my product descriptions, the text is the same in all, though the rest of the product descriptions of course vary. I am look for some MySql to alter fields, would there me something like: UPDATE products_description SET products_description = products_description - 'text to be removed"; TIA ben Link to comment Share on other sites More sharing options...
benwalsh Posted August 1, 2006 Author Share Posted August 1, 2006 any body? Link to comment Share on other sites More sharing options...
Guest Posted August 1, 2006 Share Posted August 1, 2006 I'm in a good mood so I'll give you the code... // Language ID of the description, 1 should work on English only catalog define('LANGUAGE_ID' , 1); // Define the text to be search for define('FIND_PATTERN', 'text to be replace'); // Define the text that will be replaced // '' (blank string) means it will be removed define('REPLACE_TEXT', 'new text'); // Function to replace the text and update the description function updateDescription($pID, $desc){ $desc = eregi_replace(FIND_PATTERN, REPLACE_TEXT, $desc); $update = array('products_description' => $desc); tep_db_perform(TABLE_PRODUCTS_DESCRIPTION, $update, 'update', "products_id = '".$pID."' AND language_id = '".LANGUAGE_ID."'"); } // SQL to get all the descriptions $sql = "SELECT products_id, products_description FROM " . TABLE_PRODUCTS_DESCRIPTION . " WHERE language_id = '".LANGUAGE_ID."'"; $query = tep_db_query($sql); // Loop the results and update the descriptions while($result = tep_db_fetch_array($query)){ updateDescription($result['products_id'], $result['products_description']); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.