Mercurial > hg > ywww
comparison php/read/getBookDetails.php @ 15:385ddd7c4b55 testing
use test_db.php to get mysqld_test instance
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Sun, 19 Feb 2017 16:17:53 +0000 |
parents | 5aa24c984a3b |
children |
comparison
equal
deleted
inserted
replaced
14:1477b5e6dd16 | 15:385ddd7c4b55 |
---|---|
57 | 57 |
58 $output .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; | 58 $output .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"; |
59 $output .= "<BookDetails>"; | 59 $output .= "<BookDetails>"; |
60 | 60 |
61 $proceed = true; | 61 $proceed = true; |
62 include "../../../private/db.php"; | 62 include "../../../../private/db_test.php"; |
63 | 63 |
64 $query = "CALL b_getBookInfo('$isbn', $loc)"; | 64 $query = "CALL b_getBookInfo('$isbn', $loc)"; |
65 //select Timestamp,Title,Author,Binding,DeweyDecimal,ImageURL,SalesRank,PublicationDate,Publisher,Genre1,Genre2,Genre3 from books where ISBN = '$isbn'"; | 65 //select Timestamp,Title,Author,Binding,DeweyDecimal,ImageURL,SalesRank,PublicationDate,Publisher,Genre1,Genre2,Genre3 from books where ISBN = '$isbn'"; |
66 //echo $query; | 66 //echo $query; |
67 $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); | 67 $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); |
96 $output .= "<Genre3>" . htmlspecialchars($rows["Genre3"]) . "</Genre3>"; | 96 $output .= "<Genre3>" . htmlspecialchars($rows["Genre3"]) . "</Genre3>"; |
97 $output .= "<ProductGroup>Book</ProductGroup>"; | 97 $output .= "<ProductGroup>Book</ProductGroup>"; |
98 } | 98 } |
99 } | 99 } |
100 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop | 100 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop |
101 include "../../../private/db.php"; | 101 include "../../../../private/db_test.php"; |
102 | 102 |
103 if($proceed == true) | 103 if($proceed == true) |
104 { | 104 { |
105 include "aws_signed_request.php"; | 105 include "aws_signed_request.php"; |
106 //book does not exist already so look up all the info from browse nodes.... | 106 //book does not exist already so look up all the info from browse nodes.... |
212 | 212 |
213 if (preg_match("<Error>",$out)) { | 213 if (preg_match("<Error>",$out)) { |
214 $xml = new SimpleXMLElement($out); | 214 $xml = new SimpleXMLElement($out); |
215 $resName=$xml->getName(); | 215 $resName=$xml->getName(); |
216 $code=$xml->Error->Code; | 216 $code=$xml->Error->Code; |
217 file_put_contents('/var/ywww/debug/phpDebug',"Losing gBD: $resName, $code\n",FILE_APPEND); | 217 file_put_contents('/var/test/ywww/debug/testDebug',"Losing gBD: $resName, $code\n",FILE_APPEND); |
218 if ($code=='RequestThrottled') { | 218 if ($code=='RequestThrottled') { |
219 usleep(200000); // Try to reduce throttling until we get a | 219 usleep(200000); // Try to reduce throttling until we get a |
220 // principled solution in place | 220 // principled solution in place |
221 } | 221 } |
222 else { | 222 else { |
223 file_put_contents('/var/ywww/debug/phpDebug',"parms bd: ". | 223 file_put_contents('/var/test/ywww/debug/testDebug',"parms bd: ". |
224 print_r($parameters,TRUE)."\n",FILE_APPEND); | 224 print_r($parameters,TRUE)."\n",FILE_APPEND); |
225 if ($code=="") { | 225 if ($code=="") { |
226 file_put_contents('/var/ywww/debug/phpDebug',"error elt:\n$out\n",FILE_APPEND); | 226 file_put_contents('/var/test/ywww/debug/testDebug',"error elt:\n$out\n",FILE_APPEND); |
227 } | 227 } |
228 } | 228 } |
229 } | 229 } |
230 else { | 230 else { |
231 $xml = new SimpleXMLElement($out); | 231 $xml = new SimpleXMLElement($out); |
232 //use this xml to pull out the necessary information and save it | 232 //use this xml to pull out the necessary information and save it |
233 set_error_handler(function () { | 233 set_error_handler(function () { |
234 global $out,$isbn; | 234 global $out,$isbn; |
235 file_put_contents('/var/ywww/debug/phpDebug', | 235 file_put_contents('/var/test/ywww/debug/testDebug', |
236 "Caught one bd: ".$isbn, | 236 "Caught one bd: ".$isbn, |
237 FILE_APPEND); | 237 FILE_APPEND); |
238 file_put_contents('/var/ywww/debug/phpDebug', | 238 file_put_contents('/var/test/ywww/debug/testDebug', |
239 print_r($out, TRUE)."\n", | 239 print_r($out, TRUE)."\n", |
240 FILE_APPEND); | 240 FILE_APPEND); |
241 } ); | 241 } ); |
242 | 242 |
243 $title=""; | 243 $title=""; |
320 | 320 |
321 if($salesRank == "") | 321 if($salesRank == "") |
322 $salesRank = "null"; | 322 $salesRank = "null"; |
323 | 323 |
324 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop | 324 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop |
325 include "../../../private/db.php"; | 325 include "../../../../private/db_test.php"; |
326 | 326 |
327 $title = strtr($title, '"', "'"); | 327 $title = strtr($title, '"', "'"); |
328 $queryInsert = "CALL b_addNewBook(\"$isbn\",\"$title\", \"$author\",\"$binding\",\"$imageURL\", $dewey, $salesRank,\"$pubDate\",\"$publisher\",$g1,$g2,$g3,$loc)"; | 328 $queryInsert = "CALL b_addNewBook(\"$isbn\",\"$title\", \"$author\",\"$binding\",\"$imageURL\", $dewey, $salesRank,\"$pubDate\",\"$publisher\",$g1,$g2,$g3,$loc)"; |
329 //echo $queryInsert; | 329 //echo $queryInsert; |
330 | 330 |