public function mysql_save() { $new = false; if ($this->id == 0) { $new = true; } $lid = parent::mysql_save(); if ($new) { $ts = TestSession::from_mysql_id($lid); $ts->hash = TestSession::generate_hash($lid); $ts->mysql_save(); } return $lid; }