Mercurial > hg > LGToc
diff edit_section_db.php @ 3:5d0bfd909857
modify updating to sections_index table when deletion/recovery
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Fri, 20 Mar 2015 15:32:58 +0100 |
parents | bd46d26a7b18 |
children | 373c8ecad8b4 |
line wrap: on
line diff
--- a/edit_section_db.php Fri Mar 20 11:32:06 2015 +0100 +++ b/edit_section_db.php Fri Mar 20 15:32:58 2015 +0100 @@ -176,6 +176,36 @@ $section_id = mysql_insert_id(); } + + if ($deleted == 1) { + // deleted section from sections_index where id = $section_id + $qry = "DELETE FROM sections_index WHERE id=".$section_id; + $rst = mysql_query($qry); + if (!$rst) { + break; // handle to ROLLBACK + } + + } else { + $qry = "SELECT * FROM sections_index WHERE id=".$section_id; + $rst = mysql_query($qry); + if (!$rst) { + break; // handle to ROLLBACK + } + if (mysql_num_rows($rst) == 0) { + $qry = "INSERT INTO sections_index (id,name,books_id,section_after,start_page,end_page,level,split_from) VALUES + (".$section_id.",'".$name."','".$books_id."','".$section_after."',".$start_page. + ",".$end_page.",".$level.",".$split_from.")"; + // recover section in sections_index table where id = $section_id + $rst = mysql_query($qry); + if (!$rst) { + break; // handle to ROLLBACK + } + } + + } + + // query for sections_revisions table + $str="("; $str.="'".$name."',"; $str.="'".$books_id."',";