public function save($isNew = false) { $idUser = $_POST["idUser"]; $data = array("title" => $this->stringify(trim($this->title)), "description" => $this->stringify($this->description), "status" => $this->stringify($this->status), "resp_name" => $this->stringify($this->resp_name), "resp_contact" => $this->stringify($this->resp_contact), "org_id" => $this->numeric($this->org_id)); //create a new database object. $db = new DB(); //if object is already registered and we're //just updating their info. if (!$isNew) { //update the row in the database $db->update($data, 'projects', 'id = ' . $this->id); } else { //if the user is being registered for the first time. $this->id = $db->insert($data, 'projects'); $mails = AuditTrail::createEvent('project', $this->id, 'add new', $idUser, false); } return true; }