You can use this command to add XML formatted update commands to an update query.

Make sure the XML is valid as Solarium will not check this. If you are constructing these strings in your own code, you should probably be using the other commands Solarium provides to build your update query.


This command has no options.




// create a client instance
$client = new Solarium\Client($adapter, $eventDispatcher, $config);

// get an update query instance
$update = $client->createUpdate();

// create an XML string with a valid update command
$xml = '
        <field name="id">125</field>
        <field name="name">testdoc-3</field>
        <field name="price">325</field>
        <field name="id">126</field>
        <field name="name">testdoc-4</field>
        <field name="price">375</field>

// 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

// 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();