PHP API, insert

Hello!

Software:


  • Windows 2000 Professional + SP3
  • Tamino 4.1.4.1
  • Apache Web Server 1.3.22
  • PHP 4.3.2


I just downloaded new PHP API for Tamino:
http://developer.softwareag.com/tamino/download.htm#phpapi

Using these two scrips:
- TaminoAPI.php,
- TaminoHelperFunctions.php
I can execute query to Tamino. It is simple. :)Example script example01.php works good.

Unfortunately, I cannot insert new documents into databases using TaminoAPI.php :frowning:

So, how can I add new record? For sample code, I will be very grateful.

In advance, thanks a lot!

best regards,
Dariusz Baumann

Hi Dariusz,

Hereโ€™s an example:-

  
// code fragment to insert a document

$database = "mydb";
$tamino = &new TaminoAPI("localhost", "80", $database, "", "");

$xml = "<?xml version='1.0'?>";
$xml .= "<somedocument>xxxxx</somedocument>";

if ($tamino->process($xml)) {
 echo "document inserted ok";
} else {
 echo "General failure inserting document";
 thfPrintError($tamino);
}



Hope this helps.

Stuart Fyffe-Collins
Software AG (UK) Ltd.

Hello Stuart!

First of all, thanks a lot for a very quick answer!

Inserting to Tamino new documents now works pretty good! :slight_smile:

Now, I need to modify data in my database. I just wrote a sample code which returning all value nodes:

Here is example sample data:



Franz
M

Hi Dariusz,

to modify only single elements or attributes of a document, you will be much easier off if you use the XQuery update operations instead of loading a whole document from Tamino, changing it and storing it back into Tamino. The PHP API provides an xquery()-method.

You could do something like the following:

$xquery  = "update for \$a in input()/myDoctype ".
           "where \$a/myElement=\"myValue\" ".
           "do replace \$a/myElement ".
           "with <myElement>myNewValue</myElement>";
$tamino->xquery($xquery);



regards,
Heiko