Page 1 of 1

update api usage

Posted: Fri Dec 04, 2015 1:14 am
by vanmark
I am new to LogicalDOC.

I am trying to follow the UPDATE function in the DocumentService API using the PHP template.

I don't understand how you are updating a specific document. Isn't the UPDATE function supposed to be a stand alone process. If you are using the 'sid' number, how does the function know which document to update. In the example, there is no 'docid' found.

* ***************/
print_r ( "UPDATE\r\n" );

// Maybe we want to change some metadata informations
$udoc ['title'] = 'PHP Changed Title';
$udoc ['source'] = 'PHP-SOAP';
$udoc ['sourceAuthor'] = 'myself';
$udoc ['sourceDate'] = '2009-06-10';
$udoc ['sourceType'] = 'sourceType';
$udoc ['coverage'] = 'coverage';
$udoc ['language'] = 'en';
$udoc ['tags'] = array ('PHP', 'SOAP', 'webservice' );
$udoc ['sourceId'] = 'sourceId';
$udoc ['object'] = 'object';
$udoc ['recipient'] = 'recipient';
$udoc ['templateName'] = '';
$udoc ['templateFields'] = null;

$cdp = array ('sid' => $sid, 'document' => $udoc ); <---- you are only using the 'sid', which is session id. How do you know what document is being updated?

$result = $documentClient->update ( $cdp );
print_r ( $result );

Maybe I am not understanding how the update works; do you have to read the document first, or, does this only work on a newly created document? The example shows how to create first, then flows down.


Re: update api usage

Posted: Wed Dec 09, 2015 10:25 am
by agaspa
Hi vanmark,

your are referring to the example Document_CRUD.php in PHP examples.

As you see in the $cdp array there are 2 parameters: $sid and $udoc
$cdp = array ('sid' => $sid, 'document' => $udoc );

The last one is a key value array (a Map)
in which there are all the fields of the document we are updating.

In that particular example there are no errors, what you see in the point you evidenced are just the fields
we want to update, the field id ($udoc['id']) was populated before when we retrieved the document from the repository

Code: Select all

     // We save the document info in order to be able to update it subsequently
    $udoc = (array) $result->document; // convert a stdClass to array
See also the documentation ... ocument.29

Re: update api usage

Posted: Mon Dec 14, 2015 9:29 am
by agaspa
There is an update about this.
Last week we published a new version of the PHP web-service examples for LogicalDOC 7.4.
You can download it from the project on SourceForge ... 0CE%207.4/
Here below I report the direct link ... p/download