Skip to content

User::save

James Cobban edited this page May 31, 2021 · 7 revisions

$user->save($xml)

Up: class User

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 $record‑>isExisting() is false this inserts a new record into the table. The value of the primary key is not passed in the INSERT if it is an auto-increment field, whose value will be determined by the database server. If $record->isExisting() is true the existing database record is updated. If the record was inserted or there were updates that needed to be applied to the database this method returns 1, otherwise it returns 0.

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. 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'". Otherwise no output is generated. Use of this parameter is deprecated. Callers should omit the parameter and use $user->getLastSqlCmd() instead.

The class User extends this method to ensure that when a new record is inserted into the database that the row number generated by the database server is copied into the 'id' field of the record.

Next: class UserSet

Clone this wiki locally