public function mysql_save_from_post($post) { $lid = parent::mysql_save_from_post($post); if ($this->id != 0) { $this->delete_object_links(TestVariable::get_mysql_table()); $i = 0; } $i = 0; if (array_key_exists("parameters", $post)) { foreach ($post["parameters"] as $param) { $p = json_decode($param); $var = new TestVariable(); $var->description = $p->description; $var->name = $p->name; $var->index = $i; $var->type = 0; $var->Test_id = $lid; $var->mysql_save(); $i++; } } if (array_key_exists("returns", $post)) { foreach ($post["returns"] as $ret) { $r = json_decode($ret); $var = new TestVariable(); $var->description = $r->description; $var->name = $r->name; $var->index = $i; $var->type = 1; $var->Test_id = $lid; $var->mysql_save(); $i++; } } if (array_key_exists("deleteLogs", $post)) { if ($post["deleteLogs"] == "*") { $sql = sprintf("DELETE FROM `%s` WHERE `Test_id`=%s", TestSessionLog::get_mysql_table(), $lid); if (!mysql_query($sql)) { return json_encode(array("result" => -6, "message" => mysql_error())); } } else { $logs = json_decode($post["deleteLogs"]); foreach ($logs as $log) { $log = TestSessionLog::from_mysql_id($log); if ($log != null) { $log->mysql_delete(); } } } } $obj = static::from_mysql_id($lid); if ($obj != null) { $xml_hash = $obj->calculate_xml_hash(); $obj->xml_hash = $xml_hash; $obj->mysql_save(); } return $lid; }