Skip to content

Name::save

James Cobban edited this page Nov 22, 2019 · 2 revisions

$name->save($xml)

Up: class Name

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 $name‑>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 $name->isExisting() is true the existing database record is updated. This method extends the base implementation by suppressing the update if the associated instance of class Person has not yet been inserted into the database. For a married name instance it suppresses the update if the associated instance of class Family has not yet been inserted into the database.

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, 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: $name->getPerson()

Clone this wiki locally