read more...
function insertUser(&$user) {
if ($user->getDateRegistered() == null) {
$user->setDateRegistered(Core::getCurrentDate());
}
if ($user->getDateLastLogin() == null) {
$user->setDateLastLogin(Core::getCurrentDate());
}
$this->update(
sprintf('INSERT INTO users
(username, password, salutation, first_name, middle_name, initials, last_name, dateofbirth, gender, affiliation, email, url, phone, fax, mailing_address, country, locales, date_last_email, date_registered, date_validated, date_last_login, must_change_password, disabled, disabled_reason, auth_id, auth_str)
VALUES
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, %s, %s, %s, %s, ?, ?, ?, ?, ?)',
$this->datetimeToDB($user->getDateLastEmail()), $this->datetimeToDB($user->getDateRegistered()), $this->datetimeToDB($user->getDateValidated()), $this->datetimeToDB($user->getDateLastLogin())),
array(
$user->getUsername(),
$user->getPassword(),
$user->getSalutation(),
$user->getFirstName(),
$user->getMiddleName(),
$user->getInitials(),
$user->getLastName(),
$user->getDateOfBirth(),
$user->getGender(),
$user->getAffiliation(),
$user->getEmail(),
$user->getUrl(),
$user->getPhone(),
$user->getFax(),
$user->getMailingAddress(),
$user->getCountry(),
join(':', $user->getLocales()),
$user->getMustChangePassword() ? 1 : 0,
$user->getDisabled() ? 1 : 0,
$user->getDisabledReason(),
$user->getAuthId()=='' ? null : (int) $user->getAuthId(),
$user->getAuthStr()
)
);
…
function updateObject(&$user) {
if ($user->getDateLastLogin() == null) {
$user->setDateLastLogin(Core::getCurrentDate());
}
$this->updateLocaleFields($user);
return $this->update(
sprintf('UPDATE users
SET username = ?,
password = ?,
salutation = ?,
first_name = ?,
middle_name = ?,
initials = ?,
last_name = ?,
dateofbirth = ?,
gender = ?,
affiliation = ?,
email = ?,
url = ?,
phone = ?,
fax = ?,
mailing_address = ?,
country = ?,
locales = ?,
date_last_email = %s,
date_validated = %s,
date_last_login = %s,
must_change_password = ?,
disabled = ?,
disabled_reason = ?,
auth_id = ?,
auth_str = ?
WHERE user_id = ?',
$this->datetimeToDB($user->getDateLastEmail()), $this->datetimeToDB($user->getDateValidated()), $this->datetimeToDB($user->getDateLastLogin())),
array(
$user->getUsername(),
$user->getPassword(),
$user->getSalutation(),
$user->getFirstName(),
$user->getMiddleName(),
$user->getInitials(),
$user->getLastName(),
$user->getDateOfBirth(),
$user->getGender(),
$user->getAffiliation(),
$user->getEmail(),
$user->getUrl(),
$user->getPhone(),
$user->getFax(),
$user->getMailingAddress(),
$user->getCountry(),
join(':', $user->getLocales()),
$user->getMustChangePassword() ? 1 : 0,
$user->getDisabled() ? 1 : 0,
$user->getDisabledReason(),
$user->getAuthId()=='' ? null : (int) $user->getAuthId(),
$user->getAuthStr(),
(int) $user->getId(),
)
);
}
…
And now I have DB error: Unknown field ‘dateofbirth’.
Does it mean I have to manually prepare DB somehow or did I miss something?