![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
$result = mysql_query("SELECT `termid` FROM connected_texts");
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
$orig_term_tax_id = $row['termid'];
$result2 = mysql_query("SELECT * FROM term_relationships WHERE `term_taxonomy_id` = '$orig_term_tax_id'");
while ($row2 = mysql_fetch_array($result2, MYSQL_BOTH)) {
$objectid_textid = $row2[0];
if (!$bookpart) {
$result3= mysql_query("SELECT `bookpart` FROM `texts` WHERE `textid`='$objectid_textid'");
while ($row3 = mysql_fetch_array($result3, MYSQL_BOTH)) {
$bookpart = $row3['bookpart'];
if ($bookpart == '1') {
$bookno = $objectid_textid;
$result4= mysql_query("UPDATE connected_texts SET `textid` = '$bookno' WHERE `termid` = '$orig_term_tax_id'");
}
}
}
$result3= mysql_query("SELECT `bookpart` FROM `texts` WHERE `textid`='$objectid_textid'");
while ($row3 = mysql_fetch_array($result3, MYSQL_BOTH)) {
$result4= mysql_query("UPDATE texts SET `book` = '$bookno' WHERE `textid` = '$objectid_textid'");
}
}
$bookpart = '';
}
It's amazing what your brain can do when it's not got two tons of unhappy perched on top.
while ($row = mysql_fetch_array($result, MYSQL_BOTH)) {
$orig_term_tax_id = $row['termid'];
$result2 = mysql_query("SELECT * FROM term_relationships WHERE `term_taxonomy_id` = '$orig_term_tax_id'");
while ($row2 = mysql_fetch_array($result2, MYSQL_BOTH)) {
$objectid_textid = $row2[0];
if (!$bookpart) {
$result3= mysql_query("SELECT `bookpart` FROM `texts` WHERE `textid`='$objectid_textid'");
while ($row3 = mysql_fetch_array($result3, MYSQL_BOTH)) {
$bookpart = $row3['bookpart'];
if ($bookpart == '1') {
$bookno = $objectid_textid;
$result4= mysql_query("UPDATE connected_texts SET `textid` = '$bookno' WHERE `termid` = '$orig_term_tax_id'");
}
}
}
$result3= mysql_query("SELECT `bookpart` FROM `texts` WHERE `textid`='$objectid_textid'");
while ($row3 = mysql_fetch_array($result3, MYSQL_BOTH)) {
$result4= mysql_query("UPDATE texts SET `book` = '$bookno' WHERE `textid` = '$objectid_textid'");
}
}
$bookpart = '';
}
It's amazing what your brain can do when it's not got two tons of unhappy perched on top.
no subject
Date: 24 Jun 2010 03:20 am (UTC)no subject
Date: 13 Jul 2010 07:07 pm (UTC)no subject
Date: 24 Jun 2010 01:57 pm (UTC)no subject
Date: 13 Jul 2010 07:08 pm (UTC)Yeah, it's a snippet of code from transferring/converting a WP-based CMS into a free-standing fiction archive.
no subject
Date: 24 Jun 2010 05:02 pm (UTC)no subject
Date: 13 Jul 2010 07:12 pm (UTC)Incorporating flat-files/CSV into WP, though?
Try more like two hundred lines of code -- and that's just for the one-shots. If a chapter was part of a book, add another fifty lines of code on top of that. The number of functions and triggers and switches that WP demanded for every bleeding entry just doubled and tripled and quadrupled the code, until it really would've been less time to just bloody well cut and paste and click for every entry, instead of trying to "save time" by uploading into the backend.
Sheesh.
On the other hand, nothing has ever taught me as much about database structures and organization and relational many-to-many logic as that whole *cough* learning experience with Wordpress. In that sense, the experience was frustrating but also infinitely invaluable, I've found. I certainly don't think I'd have have the facility I do now with database design if I hadn't gone through that.