|
From: Jonathan H. <hen...@ya...> - 2005-05-04 22:01:24
|
I can achieve the desired results - which is an update using
$model3->remove(new Statement($subject , $predicate, $object));
$model3->add(new Statement($subject , $predicate, $newObject));
Of course this is not handled as a complete transaction, and it could remove
without adding, or visa versa. No way to add a rollback, or undo (which would
be nice)
So, is replace functionally equivilent? It appears not because the $newObject
will replace anything unless it is null. It correctly finds the objects I am
seeking, but replaces $subject and $predicate too.
perhaps another handy function would only replace the object
in mem model for example (untested)
foreach($this->triples as $key => $value) {
if (
($this->triples[$key]->subj->equals($subject)) and
($this->triples[$key]->pred->equals($predicate)) and
($this->triples[$key]->obj->equals($object))
)
$this->triples[$key]->obj = $replacement;
}
--- Jonathan Hendler <hen...@ya...> wrote:
> Why is the replace function disabled in the INF modes?
>
> I also get an error when using replace on a DB model -
>
> "Fatal error: RDFAPI error (class: DbModel; method: find): Parameter
> mismatch
> in [my include path]/rdfapi-php/api/model/DbModel.php on line 669"
>
> occurs with :
>
> foreach ($result as $object)
> {
>
> $subject = $object['?subject']->uri;
> $predicate = $object['?predicate']->uri;
> $object = $object['?object']->label; // (assuming this is a literal)
>
> $newObject = $model->createLiteral(5);
> $dbModel->replace($subject , $predicate, $object, $newObject);
>
> }
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: NEC IT Guy Games.
> Get your fingers limbered up and give it your best shot. 4 great events, 4
> opportunities to win big! Highest score wins.NEC IT Guy Games. Play to
> win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
> _______________________________________________
> Rdfapi-php-interest mailing list
> Rdf...@li...
> https://lists.sourceforge.net/lists/listinfo/rdfapi-php-interest
>
|