public function saveentry() { $datastore = $this->param("table", null); $entry = $this->param("entry", null); if ($datastore && $entry) { $collection = "datastore" . $datastore["_id"]; $entry["modified"] = time(); if (!isset($entry["_id"])) { $entry["created"] = $entry["modified"]; } $this->app->db->save("datastore/{$collection}", $entry); } return $entry ? json_encode($entry) : '{}'; }