Skip to content
Snippets Groups Projects
Commit 509010ea authored by Anton Bagliy's avatar Anton Bagliy
Browse files

ADD: update subject name with the same extid on sync #426

parent e4072350
Branches
No related merge requests found
DROP function if EXISTS public.subject_update(psubjectid integer, psubjectname character varying);
CREATE OR REPLACE FUNCTION public.subject_update(psubjectid integer, psubjectname character varying)
RETURNS integer
LANGUAGE plpgsql
AS $function$
DECLARE rowUpd int;
begin
UPDATE subjects SET name = psubjectname WHERE id = psubjectid;
get diagnostics rowUpd = ROW_COUNT;
RETURN rowUpd-1;
END
$function$;
......@@ -57,6 +57,12 @@ class Model_Subject
if ($id == -1) {
$id = self::createOrUpdate($name, $abbr, $facultyID, $extID);
} else {
$sql = 'SELECT * FROM Subject_Update(:ID, :subjName) AS "RES"';
$res = DB::query(Database::SELECT, $sql)
->param(':ID', $id)
->param(':subjName', $name)
->execute()->get('RES');
}
return $id;
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment