Changeset 93613 in spip-zone
- Timestamp:
- Dec 13, 2015, 11:40:09 AM (5 years ago)
- Location:
- _plugins_/indexer/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/indexer/trunk/inc/indexer.php
r93516 r93613 340 340 * faire un DUMP SQL de notre base sphinx 341 341 * index: nom de l'index (table) a dumper 342 * format: format de sortie ("sphinx" ou "mysql") 342 343 * dest: fichier destination (null: stdout) 343 344 * bloc : nombre d'enregistrements a rapatrier a chaque tour (maximum 1000) … … 347 348 // indexer_dumpsql(SPHINX_DEFAULT_INDEX, 'tmp/indexer.sql', 1000); 348 349 */ 349 function indexer_dumpsql($index = null, $ dest = null, $bloc = 100) {350 function indexer_dumpsql($index = null, $format = 'sphinx', $dest = null, $bloc = 100) { 350 351 if (is_null($dest)) { 351 352 $dest = 'php://stdout'; … … 397 398 $fields = []; 398 399 foreach($all['query']['docs'] as $doc) { 399 $fields[] = "\t" . '`' . $doc['Field'] .'` ' . $doc['Type']; 400 if ($format == 'sphinx') { 401 $fields[] = "\t" . '`' . $doc['Field'] .'` ' . $doc['Type'] ; 402 } 403 else if ($format == 'mysql') { 404 switch ($doc['Type']) { 405 case 'field': 406 break; 407 case 'bigint': 408 $type = 'BIGINT(21) NOT NULL'; 409 $fields[] = "\t" . '`' . $doc['Field'] .'` ' . $type; 410 break; 411 case 'timestamp': 412 $type = 'TINYTEXT DEFAULT \'\' NOT NULL'; 413 $fields[] = "\t" . '`' . $doc['Field'] .'` ' . $type; 414 break; 415 case 'json': 416 $type = 'TEXT DEFAULT \'\' NOT NULL'; 417 $fields[] = "\t" . '`' . $doc['Field'] .'` ' . $type; 418 break; 419 case 'string': 420 $type = 'LONGTEXT DEFAULT \'\' NOT NULL'; 421 $fields[] = "\t" . '`' . $doc['Field'] .'` ' . $type; 422 break; 423 } 424 } 400 425 } 401 426 $comm .= join(",\n", $fields); 402 427 $comm .= " 403 ) 428 ); 404 429 405 430 -
_plugins_/indexer/trunk/spip-cli/IndexerIndexer.php
r93604 r93613 54 54 null 55 55 ) 56 ->addOption( 57 'format', 58 'f', 59 InputOption::VALUE_OPTIONAL, 60 'format de sortie : sphinx ou mysql', 61 'sphinx' 62 ) 56 63 ; 57 64 } … … 61 68 62 69 $index = $input->getOption('index'); 70 $format = $input->getOption('format'); 63 71 64 indexer_dumpsql($index );72 indexer_dumpsql($index, $format); 65 73 } 66 74 }
Note: See TracChangeset
for help on using the changeset viewer.