From: <van...@ce...> - 2005-03-11 09:58:36
|
Hello, I have some questions concerning the function replace from the DbModel.php. First of all, I don't understand the conditions when the script checks the correctness of the passed params in particular the lines 666 to 668. I don't understand why the replacement param could not be a Literal or a blanknode when the subject or the predicate is not null. Can you give me some precisions? Secondly, I don't understand why we set the subject or the predicate in the sql query. (lines 680 to 688) If I understand the goal of the function, we can change only the object. So, why we should set also the subject or the predicate? In addition, when the function changes the subject or the predicate, it changes with the replacement value. I think it's not the normal behaviour. In my script, this function changes the subject, the predicate and the object with the same value, the replacement param. Finally, at line 689, why is there a condition of the object. In this case, we have to put the old object in param. The old object can't be null. Why? I need this functions to update some statements of my database. For the moment, the original function don't allow me to change the object of the statement when I give the subject and the predicate. I have modified the function for my needs and for me the function should look like this one: function replace($subject, $predicate, $object, $replacement) { // check the correctness of the passed parameters if ( ((!is_a($subject, 'Resource') && $subject != NULL) || (!is_a($predicate, 'Resource') && $predicate != NULL) || (!is_a($object, 'Node') && $object != NULL))) { $errmsg = RDFAPI_ERROR . '(class: DbModel; method: find): Parameter mismatch'; trigger_error($errmsg, E_USER_ERROR); } if (!(!$subject && !$predicate && !$object)) { // create an update sql statement $comma = ''; $sql = 'UPDATE statements SET '; $quotedObject = $this->dbConn->qstr($replacement->getLabel()); $sql .= $comma .' object=' .$quotedObject .", object_is='" .$this->_getNodeFlag($replacement) ."' "; if (is_a($replacement, 'Literal')) { $sql .= ", l_language='" .$replacement->getLanguage() ."' " .", l_datatype='" .$replacement->getDataType() ."' "; } $sql .= 'WHERE modelID = ' .$this->modelID; $sql .= $this->_createDynSqlPart_SPO($subject, $predicate, $object); // execute the query $rs =& $this->dbConn->execute($sql); if (!$rs) echo $this->dbConn->errorMsg(); } } I'm waiting your feedbacks... :-) regards, Aurélien Van Hamme |