/
2.2.6-rawxml.php
43 lines (34 loc) · 1.02 KB
/
2.2.6-rawxml.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
require(__DIR__.'/init.php');
htmlHeader();
// create a client instance
$client = new Solarium\Client($config);
// get an update query instance
$update = $client->createUpdate();
// create an XML string with a valid update command
$xml = '
<add>
<doc>
<field name="id">125</field>
<field name="name">testdoc-3</field>
<field name="price">325</field>
</doc>
<doc>
<field name="id">126</field>
<field name="name">testdoc-4</field>
<field name="price">375</field>
</doc>
</add>
';
// or use an XML file containing a valid update command
$xmlfile = 'example.xml';
// add the XML string, the XML file and a commit command to the update query
$update->addRawXmlCommand($xml);
$update->addRawXmlFile($xmlfile);
$update->addCommit();
// this executes the query and returns the result
$result = $client->update($update);
echo '<b>Update query executed</b><br/>';
echo 'Query status: ' . $result->getStatus(). '<br/>';
echo 'Query time: ' . $result->getQueryTime();
htmlFooter();