Mercurial > hg > LGToc
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 2:bd46d26a7b18 | 3:5d0bfd909857 |
|---|---|
| 174 if ($section_id == 0) { | 174 if ($section_id == 0) { |
| 175 // set section_id from section_index if this is a new section | 175 // set section_id from section_index if this is a new section |
| 176 $section_id = mysql_insert_id(); | 176 $section_id = mysql_insert_id(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 | |
| 180 if ($deleted == 1) { | |
| 181 // deleted section from sections_index where id = $section_id | |
| 182 $qry = "DELETE FROM sections_index WHERE id=".$section_id; | |
| 183 $rst = mysql_query($qry); | |
| 184 if (!$rst) { | |
| 185 break; // handle to ROLLBACK | |
| 186 } | |
| 187 | |
| 188 } else { | |
| 189 $qry = "SELECT * FROM sections_index WHERE id=".$section_id; | |
| 190 $rst = mysql_query($qry); | |
| 191 if (!$rst) { | |
| 192 break; // handle to ROLLBACK | |
| 193 } | |
| 194 if (mysql_num_rows($rst) == 0) { | |
| 195 $qry = "INSERT INTO sections_index (id,name,books_id,section_after,start_page,end_page,level,split_from) VALUES | |
| 196 (".$section_id.",'".$name."','".$books_id."','".$section_after."',".$start_page. | |
| 197 ",".$end_page.",".$level.",".$split_from.")"; | |
| 198 // recover section in sections_index table where id = $section_id | |
| 199 $rst = mysql_query($qry); | |
| 200 if (!$rst) { | |
| 201 break; // handle to ROLLBACK | |
| 202 } | |
| 203 } | |
| 204 | |
| 205 } | |
| 206 | |
| 207 // query for sections_revisions table | |
| 208 | |
| 179 $str="("; | 209 $str="("; |
| 180 $str.="'".$name."',"; | 210 $str.="'".$name."',"; |
| 181 $str.="'".$books_id."',"; | 211 $str.="'".$books_id."',"; |
| 182 $str.="'".$section_after."',"; | 212 $str.="'".$section_after."',"; |
| 183 $str.=$start_page.","; | 213 $str.=$start_page.","; |
