{"id":277,"date":"2005-09-20T15:19:18","date_gmt":"2005-09-20T19:19:18","guid":{"rendered":"http:\/\/www.uvm.edu\/~waw\/blog\/?p=277"},"modified":"2005-09-20T15:19:18","modified_gmt":"2005-09-20T19:19:18","slug":"more-broken-landscape-code","status":"publish","type":"post","link":"https:\/\/blog.uvm.edu\/waw\/2005\/09\/20\/more-broken-landscape-code\/","title":{"rendered":"More broken Landscape code"},"content":{"rendered":"<p>I&#8217;m preparing to write a script to extract data from the LCP data base for ingestion into Dspace.<\/p>\n<p>While looking at the raw contents of the database using CocoaSQL, I noticed a bunch of records from the last few days, all with the same LS#: namely, LS00001<\/p>\n<p>This is bad.<\/p>\n<p>Go to <a href=\"http:\/\/www.uvm.edu\/perkins\/\/landscape\/search_collection\/search_collection_advanced.php\">Advanced search<\/a>, search for LS0001, see what happens.<\/p>\n<p>Looks like the maximum LS# is 10000, as in LS10000 . I&#8217;m guessing something in the old code goes whack at that magic number.<\/p>\n<p>Finally found&nbsp; the offensive line of code in \/:\/perkins\/landscape\/WORKING_FOLDER\/LS_PROCESS3.php<\/p>\n<p>Former programmer had<\/p>\n<p>&nbsp;<span style=\"font-family: courier new\">&nbsp;&nbsp; $query=&quot;SELECT RECID,FILENAME FROM VTLANDSCAPEDB ORDER BY FILENAME&quot;;<\/span><br style=\"font-family: courier new\" \/><span style=\"font-family: courier new\">&nbsp;&nbsp;&nbsp; $result=mysql_query($query) or die(&quot;Problem Here&quot;);<\/span><br style=\"font-family: courier new\" \/><span style=\"font-family: courier new\">&nbsp;&nbsp;&nbsp; While ($line= mysql_fetch_array($result)){<\/span><br style=\"font-family: courier new\" \/><span style=\"font-family: courier new\">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $LFN=$line[FILENAME];<\/span><br style=\"font-family: courier new\" \/><span style=\"font-family: courier new\">&nbsp;&nbsp;&nbsp; };<\/span><br style=\"font-family: courier new\" \/><span style=\"font-family: courier new\">&nbsp;&nbsp;&nbsp; $NFN=substr($LFN,3,10)+1;<\/span><br style=\"font-family: courier new\" \/><br \/>\nWell, first off, selecting 10,000 (or even 1000) records and looping through them all just to find the last used FILENAME is wicked inefficient &#8212; both for the PHP code and the mySQL server.<\/p>\n<p>Then, once a filename name was found, say<\/p>\n<div style=\"margin-left: 40px\">LS10000_000.jpg\n<\/div>\n<p>\nor<\/p>\n<div style=\"margin-left: 40px\">LS09000_001.jpg\n<\/div>\n<p>\n<span style=\"font-family: courier new\">substr($LFN,3,10) <\/span><span style=\"font-family: arial\">should then yield<\/p>\n<p>0000_000.jp or even <\/span>9000_001.jp . How adding 1 to that ever worked, I dunno<\/p>\n<p>New code:<\/p>\n<p><span style=\"font-family: courier new\">&nbsp;&nbsp; $query=&quot;SELECT RECID,FILENAME FROM VTLANDSCAPEDB ORDER BY FILENAME desc limit 1&quot;;<\/span><br style=\"font-family: courier new\" \/> <span style=\"font-family: courier new\">&nbsp;&nbsp;&nbsp; $result=mysql_query($query) or die(&quot;Problem Here&quot;);<\/span><br style=\"font-family: courier new\" \/> <span style=\"font-family: courier new\">&nbsp;&nbsp;&nbsp; While ($line= mysql_fetch_array($result)){<\/span><br style=\"font-family: courier new\" \/> <span style=\"font-family: courier new\">&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; $LFN=$line[FILENAME];<\/span><br style=\"font-family: courier new\" \/> <span style=\"font-family: courier new\">&nbsp;&nbsp;&nbsp; };<\/span><br style=\"font-family: courier new\" \/> <span style=\"font-family: courier new\">&nbsp;&nbsp;&nbsp; $NFN=substr($LFN,2,5)+1;<\/span><br style=\"font-family: courier new\" \/><\/p>\n<p>This fix should prevent further instances of FILENAME = LS00001_000.jpg records; however, fixing the damage done is another story.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m preparing to write a script to extract data from the LCP data base for ingestion into Dspace. While looking at the raw contents of the database using CocoaSQL, I noticed a bunch of records from the last few days, &hellip; <a href=\"https:\/\/blog.uvm.edu\/waw\/2005\/09\/20\/more-broken-landscape-code\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":7,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38506,6517],"tags":[],"class_list":["post-277","post","type-post","status-publish","format-standard","hentry","category-landscape-change","category-projects"],"_links":{"self":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/posts\/277","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/comments?post=277"}],"version-history":[{"count":0,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/posts\/277\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/media?parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/categories?post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.uvm.edu\/waw\/wp-json\/wp\/v2\/tags?post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}