Advertisement
Guest User

Untitled

a guest
Mar 8th, 2011
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.59 KB | None | 0 0
  1. #/usr/bin/bash
  2.  
  3. TEXT=`myisam_ftdump -c path/to/tables/searched_table 1`
  4.  
  5. ARR=$(echo $TEXT | tr " " "\n")
  6. SQL='
  7.    TRUNCATE TABLE  `search_suggestions`;
  8.    INSERT INTO  search_suggestions (
  9.        `weight`,
  10.        `word`
  11.    )
  12.    VALUES
  13.    '
  14.  
  15. counter=0
  16.  
  17. for val in $ARR
  18. do
  19.     offset=$(( $counter % 3 ))
  20.     if [ $offset -eq 1 ] # It's the weight
  21.     then
  22.         SQL=`echo "$SQL ( $val, "`
  23.     elif [ $offset -eq 2 ] # It's the word
  24.     then
  25.         SQL=`echo "$SQL '$val'),"`
  26.     fi
  27.     counter=$(($counter + 1))
  28. done
  29.  
  30. TARGET=`expr match "$0" '\(.*\)/.*'`
  31.  
  32. echo ${SQL%,}';' > $TARGET/search_fields.sql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement