Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/usr/bin/bash
- TEXT=`myisam_ftdump -c path/to/tables/searched_table 1`
- ARR=$(echo $TEXT | tr " " "\n")
- SQL='
- TRUNCATE TABLE `search_suggestions`;
- INSERT INTO search_suggestions (
- `weight`,
- `word`
- )
- VALUES
- '
- counter=0
- for val in $ARR
- do
- offset=$(( $counter % 3 ))
- if [ $offset -eq 1 ] # It's the weight
- then
- SQL=`echo "$SQL ( $val, "`
- elif [ $offset -eq 2 ] # It's the word
- then
- SQL=`echo "$SQL '$val'),"`
- fi
- counter=$(($counter + 1))
- done
- TARGET=`expr match "$0" '\(.*\)/.*'`
- echo ${SQL%,}';' > $TARGET/search_fields.sql
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement