2 Update
Shikiryu edited this page 2019-10-21 09:46:52 +02:00

We offered you 2 ways to Update items into the XMLDB:

Update attribute

Syntax: public function updateNodeAttribute($table, $oldAttribute, $newAttribute, $forceInsert = false)

Params:

  • $table : String : name of the table
  • $oldAttribute : Array : name of the actual attribute of the element (it will find the element thanks to it...)
  • $newAttribute : Array : same but new
  • $forceInsert : boolean : if the attribute doesn't exist do we create it ?

Example:

$xmldb = new XMLDB('db.xml');
$xmldb->updateNodeAttribute('table1', array('id', 'links'), array('id', 'zelda'));

Update child value

Syntax: public function updateNodeValue($table, $attribute = null, $child = null, $value)

Example:

$xmldb = new XMLDB('db.xml');
$xmldb->updateNodeValue('table1', array('id', 'notes'), null, 'booga!');

Note : Like in the example, you can also change the item value but it will erase all children in the process