Allow user_no, created and modified to be set on create.

This commit is contained in:
Andrew McMillan 2012-01-15 20:44:10 +13:00
parent fb3eca0b07
commit 7140963e49
2 changed files with 12 additions and 2 deletions

View File

@ -23,8 +23,8 @@ DO INSTEAD
VALUES(
COALESCE( NEW.user_no, nextval('usr_user_no_seq')),
COALESCE( NEW.user_active, TRUE),
current_timestamp,
current_timestamp,
COALESCE( NEW.created, current_timestamp),
COALESCE( NEW.modified, current_timestamp),
NEW.username, NEW.password,
COALESCE( NEW.fullname, NEW.displayname ),
NEW.email, NEW.email_ok,

View File

@ -553,6 +553,16 @@ class Principal {
throw new Exception( get_class($this).'::Create: Mandatory field "'.$k.'" is not set.');
}
}
if ( isset($this->user_no) ) {
$param_names[] = ':user_no';
$insert_fields[] = 'user_no';
$sql_params[':user_no'] = $this->user_no;
}
if ( isset($this->created) ) {
$param_names[] = ':created';
$insert_fields[] = 'created';
$sql_params[':created'] = $this->created;
}
$sql = 'INSERT INTO '.self::$db_tablename.' ('.implode(',',$insert_fields).') VALUES('.implode(',',$param_names).')';
}
else {