Search and replace with php and mysql.

Search conditions such as are indicated without ambiguities and variations (i.e. look for an entry in the field of the table), and values ​​160, 170, 180, etc. pre-bitten (by other methods) from aaa160bbb, etc., and all this should be replaced with one value.

Explanation: if 160 is found here aaa160bbb or here aaa1600000bbb is what we need.

There is a file on the file.txt hosting with values

160 170 180 

In the mysqldb database in the table mytable in the field of speed such data

 aaa160bbb ccc170ddd eee180fff 

Make a search and replace the INPUT values ​​from the txt file to 11111 to make it

 aaa11111bbb ccc11111ddd eee11111fff 

Help to do? Will normal hosting die at runtime? There can be several tens of thousands of values ​​in txt, i.e. 10,000+

  • four
    Your task is suspiciously strange. Most likely you need to revise the architecture of the database, once such tasks appear. In general, if you have digits around the numbers in the table, I would suggest creating a column or another table in which to select numbers from the rows, then build an index on this field and then look for records using the data from the file - Mike
  • and if there is aaa1600bbb , and there is a number 160 in the file, do I need to change it? Whether the hosting will die or not, only the tests will show, we can only say that it is possible (that is, not yet a fact) that it will not be sweet. But in this case, you can update in parts, i.e. updated 1K records - paused, updated another batch - again pause, etc. But in order not to pervert so much - it is better to redo the approach used, at least redo the structure of the database - BOPOH
  • Tinkering with the base structure is out of the question, just a replacement is needed - Andrei
  • Still, the question of the CROW remains: "and if there is aaa1600bbb, and there is a number 160 in the file, do I have to change it?" Plus, there are more questions: what number of values ​​are we talking about (160, 170, 180 to ....?) "10,000, 20, 30+" - is this so much in the txt file or in the database? - cyadvert
  • If the file is aaa1600bbb , and you need to replace 160 , then after the replacement you get aaa11110bbb . It is right? or so it is not necessary? - cyadvert

0