2

I'm trying to insert new item to Xml file with this code

$conn = sedna_connect($host,$database,$user,$password);
$path = dirname(__FILE__) . '/ADEDB.xml';
$file = file_get_contents($path);
sedna_load($file, 'ADEDB');

sedna_tweak_opt(SE_OPTID_AUTOCOMMIT, false);
sedna_transact_begin();

sedna_execute('
UPDATE insert 
<Employee id="3">
 <name>Louay Hamada</name>
 <bday>21/01/1986</bday>
 <reg>Homs</reg>
 <adrs>Mazzeh</adrs>
</Employee>
into doc("ADEDB")/HRSystem/Employees
');

sedna_transact_commit();
sedna_tweak_opt(SE_OPTID_AUTOCOMMIT, true);

I know that my code would be worng, but I'm not found any document or examples that helps me to pass this problem :(

Louay Hamada
  • 781
  • 1
  • 14
  • 22
  • and which problem are you talking about? – hakre Jun 11 '13 at 09:40
  • I can't add this item to xml file ! – Louay Hamada Jun 11 '13 at 09:44
  • Well, start with error tracking. Try to find out which error the system reports. If you have a support question concerning a specific product I normally suggest to contact the software vendor for your support options first *before* asking a programming question here. Just the standard trouble-shooting. In case it's a documentation or support issue, you most often find better resources there. You can later on answer your question here as well so to document how you made it. – hakre Jun 11 '13 at 10:10
  • But I don't get any errors when execute this code, and I think my question will be familiar with some people who working on Sedna and php, thank you for reply anyway. – Louay Hamada Jun 11 '13 at 10:13
  • 1
    Because you don't get any errors, you first need to take a look how to get errors. That's why I suggested you take the support route, e.g. reading documentation about *error handling* with that database client library and so on. – hakre Jun 11 '13 at 10:21
  • Maybe I don't mention that, but I also try if()..die(...sedna_error()..) to get any errors but no thing :) – Louay Hamada Jun 11 '13 at 10:29
  • Well if you don't get any error, there was *technically* no problem with the query. You probably do not check for errors when committing the transaction? – hakre Jun 11 '13 at 10:31

1 Answers1

1

There are Sedna event logs (SEDNA_HOME/data/event*.log files). Have you checked them? Is there any error message?

Have you tried to run the same update statement via se_term (Sedna Terminal)? Try also to run doc("ADEDB")/HRSystem/Employees query to see if it returns anything at all.

Do you have namespaces in your document?

Shcheklein
  • 5,979
  • 7
  • 44
  • 53
  • In Event log there is no errors. But with se_term and then query the document all new data are there !!! but if I opened xml file I can't find it. – Louay Hamada Jun 11 '13 at 18:27
  • 1
    Sedna is a database. It means it stores documents in some binary format which allows efficient XQuery execution, ACID transaction, etc ... See `SEDNA_HOME/{you-database-name}_data folder`. It contains *.sedata file. This is binary file which stores all documents of the database in a special internal representation. Some technical details you can find here http://www.slideshare.net/shcheklein/sedna-xml-database-system-internal-representation, http://panda.ispras.ru/~grinev/mypapers/sedna.pdf – Shcheklein Jun 11 '13 at 19:10
  • Okay, I understand it, but now what I can do to store new data into my XML file via above code. Thanx Shcheklein for help – Louay Hamada Jun 11 '13 at 20:01
  • 1
    For example, you can udpdate and then serialize your file either via terminal: `se_term -query "doc('ADEDB')" {database-name} > ADEDB-new.xml`, or via PHP itself. – Shcheklein Jun 11 '13 at 20:07
  • Thank you again, but how I do that with PHP ? – Louay Hamada Jun 11 '13 at 20:28
  • 1
    Just run the same query `doc('ADEDB')` - see `05-query.php` example on how to run queries and print results. – Shcheklein Jun 11 '13 at 20:48
  • I try what you say before I ask you, I doesn't work but after some work It now full fine :) Really I don't know how I can thank you :) Thank you very much. – Louay Hamada Jun 11 '13 at 21:01