Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php |
— | — | @@ -431,17 +431,23 @@ |
432 | 432 | $db =& wfGetDB( DB_MASTER ); |
433 | 433 | $subject = $data->getSubject(); |
434 | 434 | $this->deleteSubject($subject); |
| 435 | + |
| 436 | + // do bulk updates: |
| 437 | + $up_relations = array(); |
| 438 | + $up_attributes = array(); |
| 439 | + $up_longstrings = array(); |
| 440 | + $up_specials = array(); |
| 441 | + |
435 | 442 | // relations |
436 | 443 | foreach($data->getRelations() as $relation) { |
437 | 444 | foreach($data->getRelationObjects($relation) as $object) { |
438 | | - $db->insert( $db->tableName('smw_relations'), |
439 | | - array( 'subject_id' => $subject->getArticleID(), |
| 445 | + $up_relations[] = |
| 446 | + array( 'subject_id' => $subject->getArticleID(), |
440 | 447 | 'subject_namespace' => $subject->getNamespace(), |
441 | 448 | 'subject_title' => $subject->getDBkey(), |
442 | 449 | 'relation_title' => $relation->getDBkey(), |
443 | 450 | 'object_namespace' => $object->getNamespace(), |
444 | | - 'object_title' => $object->getDBkey()), |
445 | | - 'SMW::updateRelData'); |
| 451 | + 'object_title' => $object->getDBkey() ); |
446 | 452 | } |
447 | 453 | } |
448 | 454 | |
— | — | @@ -451,24 +457,22 @@ |
452 | 458 | foreach($attributeValueArray as $value) { |
453 | 459 | if ($value->getXSDValue()!==false) { |
454 | 460 | if ($value->getTypeID() !== 'text') { |
455 | | - $db->insert( $db->tableName('smw_attributes'), |
456 | | - array( 'subject_id' => $subject->getArticleID(), |
| 461 | + $up_attributes[] = |
| 462 | + array( 'subject_id' => $subject->getArticleID(), |
457 | 463 | 'subject_namespace' => $subject->getNamespace(), |
458 | 464 | 'subject_title' => $subject->getDBkey(), |
459 | 465 | 'attribute_title' => $attribute->getDBkey(), |
460 | 466 | 'value_unit' => $value->getUnit(), |
461 | 467 | 'value_datatype' => $value->getTypeID(), |
462 | 468 | 'value_xsd' => $value->getXSDValue(), |
463 | | - 'value_num' => $value->getNumericValue()), |
464 | | - 'SMW::updateAttData'); |
| 469 | + 'value_num' => $value->getNumericValue() ); |
465 | 470 | } else { |
466 | | - $db->insert( $db->tableName('smw_longstrings'), |
467 | | - array( 'subject_id' => $subject->getArticleID(), |
| 471 | + $up_longstrings[] = |
| 472 | + array( 'subject_id' => $subject->getArticleID(), |
468 | 473 | 'subject_namespace' => $subject->getNamespace(), |
469 | 474 | 'subject_title' => $subject->getDBkey(), |
470 | 475 | 'attribute_title' => $attribute->getDBkey(), |
471 | | - 'value_blob' => $value->getXSDValue()), |
472 | | - 'SMW::updateAttDataLongString'); |
| 476 | + 'value_blob' => $value->getXSDValue() ); |
473 | 477 | } |
474 | 478 | } |
475 | 479 | } |
— | — | @@ -494,15 +498,28 @@ |
495 | 499 | } else { |
496 | 500 | $stringvalue = $value; |
497 | 501 | } |
498 | | - $db->insert( $db->tableName('smw_specialprops'), |
499 | | - array('subject_id' => $subject->getArticleID(), |
500 | | - 'subject_namespace' => $subject->getNamespace(), |
501 | | - 'subject_title' => $subject->getDBkey(), |
502 | | - 'property_id' => $special, |
503 | | - 'value_string' => $stringvalue), |
504 | | - 'SMW::updateSpecData'); |
| 502 | + $up_specials[] = |
| 503 | + array('subject_id' => $subject->getArticleID(), |
| 504 | + 'subject_namespace' => $subject->getNamespace(), |
| 505 | + 'subject_title' => $subject->getDBkey(), |
| 506 | + 'property_id' => $special, |
| 507 | + 'value_string' => $stringvalue); |
505 | 508 | } |
506 | 509 | } |
| 510 | + |
| 511 | + // write to DB: |
| 512 | + if (count($up_relations) > 0) { |
| 513 | + $db->insert( $db->tableName('smw_relations'), $up_relations, 'SMW::updateRelData'); |
| 514 | + } |
| 515 | + if (count($up_attributes) > 0) { |
| 516 | + $db->insert( $db->tableName('smw_attributes'), $up_attributes, 'SMW::updateAttData'); |
| 517 | + } |
| 518 | + if (count($up_longstrings) > 0) { |
| 519 | + $db->insert( $db->tableName('smw_longstrings'), $up_longstrings, 'SMW::updateLongData'); |
| 520 | + } |
| 521 | + if (count($up_specials) > 0) { |
| 522 | + $db->insert( $db->tableName('smw_specialprops'), $up_specials, 'SMW::updateSpecData'); |
| 523 | + } |
507 | 524 | } |
508 | 525 | |
509 | 526 | function changeTitle(Title $oldtitle, Title $newtitle, $keepid = true) { |