id = (int) $this->id; return true; } /** * メンバー変数に格納された値を登録する * @return boolean True if success stored,false otherwise */ function store() { if (!$this->check()) { return false; } global $my; $userid = (int) $my->id; $now = time(); if (!$this->id) { /* * 新規登録 */ $this->created = $now; $this->created_by = $userid; } $this->modified = $now; $this->modified_by = $userid; $result = parent::store(); if (!$result) { trigger_error("Failed store: ".$this->getError(), E_USER_WARNING); return false; } if (!$this->id) { /* * 新規登録のID取得 */ $this->id = (int) $this->_db->insertid(); } return true; } /** * ID を取得 * @return int id */ function id() { return (int) $this->id; } /** * 登録日時を取得 * @param string date_format * @return mixed created timestamp or formated string */ function created($date_format = null) { if (!$date_format) { return (int) $this->created; } else { return date($date_format, $this->created); } } /** * 登録ユーザを取得 * @param string key * @return mosUser created user or user value */ function created_by($key = null) { $id = (int) $this->created_by; if (!$id) return null; $user = new mosUser($this->_db); $result = $user->load($id); if (!$result) { trigger_error( "Failed load created user: ".$user->getError() , E_USER_WARNING ); return null; } return $key ? $user->$key : $user; } /** * 更新日時を取得 * @param string date_format * @return mixed modified timestamp or formated string */ function modified($date_format = null) { if (!$date_format) { return (int) $this->modified; } else { return date($date_format, $this->modified); } } /** * 更新ユーザを取得 * @param string key * @return mosUser modified user or user value */ function modified_by($key = null) { $id = (int) $this->modified_by; if (!$id) return null; $user = new mosUser($this->_db); $result = $user->load($id); if (!$result) { trigger_error( "Failed load modified user: ".$user->getError() , E_USER_WARNING ); return null; } return $key ? $user->$key : $user; } }