|
Revision 1, 1.0 KB
(checked in by anonymous, 7 years ago)
|
|
initial import
|
| Line | |
|---|
| 1 | #!/usr/bin/php |
|---|
| 2 | <? |
|---|
| 3 | include ('../includes/includes.inc.php'); |
|---|
| 4 | include ('../includes/config/global.inc.php'); |
|---|
| 5 | |
|---|
| 6 | $db =& DB::connect($dsn); |
|---|
| 7 | if (DB::isError($db)) |
|---|
| 8 | error_log($_SERVER['HTTP_HOST'].' | '.__FILE__.' | Connexion SQL impossible : '.$db->getMessage()); |
|---|
| 9 | |
|---|
| 10 | $db->setFetchMode(DB_FETCHMODE_ASSOC); |
|---|
| 11 | |
|---|
| 12 | $db->query('TRUNCATE TABLE community_keyword'); |
|---|
| 13 | |
|---|
| 14 | $comm_r = $db->query('SELECT id_comm, name, description, id_cat FROM community'); |
|---|
| 15 | while($comm = $comm_r->fetchRow()) |
|---|
| 16 | { |
|---|
| 17 | $idx++; |
|---|
| 18 | print $idx.'. "'.$comm['name'].'" '; |
|---|
| 19 | $array_description = explode(' ', $comm['description']); |
|---|
| 20 | $array_name = explode(' ', $comm['name']); |
|---|
| 21 | |
|---|
| 22 | $array = array_merge($array_description, $array_name); |
|---|
| 23 | |
|---|
| 24 | foreach($array as $elemt) |
|---|
| 25 | { |
|---|
| 26 | $elemt = ereg_replace("(.*)s$", "\\1", $elemt); |
|---|
| 27 | |
|---|
| 28 | if( strlen($elemt)>2 && !ereg("^http", $elemt) ) |
|---|
| 29 | { |
|---|
| 30 | $sndx = get_mysql_soundex($elemt); |
|---|
| 31 | $db->query('INSERT INTO community_keyword SET key_sndx=?, id_comm=?, id_cat=?', array($sndx, $comm['id_comm'], $comm['id_cat'])); |
|---|
| 32 | print '.'; |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | print "\n"; |
|---|
| 36 | |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | $db->disconnect(); |
|---|
| 40 | ?> |
|---|