Skip to content

Person::save

James Cobban edited this page Nov 3, 2019 · 4 revisions

$person->save($xml)

Up: class Person

This method updates the record contents in the database server. If previously detected errors have been accumulated in $this‑>msg this method suppresses the update, generates a warning that includes the text of the messages to explain why the record was not updated, and returns 0. If $person‑>isExisting() is false this inserts a new record into the table. The value of the primary key is not passed in the INSERT as it is an auto-increment field, whose value will be determined by the database server. If $person->isExisting() is true the existing database record is updated.

The method is extended so that the fields id, idir, surnamesoundex, added, addedtime, updated,and updatedtime are filled in from the SQL server.

parameter description
$xml If the value is boolean true then a representation of the SQL command issued to update the database is printed on the output enclosed in an XML <cmd> tag. If the value is a string then the representation of the SQL command issued to update the database is printed on the output enclosed in an XML <$xml> tag. If the leading characters of the string contain spaces these are extracted and used as an indentation value before the tag and end-tag. If there are any characters after a valid XML tag name these are extracted and presented only in the opening tag. Otherwise no output is generated.

For example if the text is to be displayed as part of a web page then you may set the parameter to 'p' or " p class='cssclassname'".

The method returns boolean false if the method was unable to update the database, it returns 1 if the method updated the database record, or 0 if the database did not need to be updated because there were no changes to the record.

The method throws an Exception if user is not authorized to update the database.

Next: $person->delete()

Clone this wiki locally