Mercurial > hg > ywww
comparison php/read/getBookDetails.php @ 46:b7376319d25a
centralise db query even more
| author | Charlie Root |
|---|---|
| date | Sun, 06 Jan 2019 12:15:42 -0500 |
| parents | 38d209611508 |
| children | da133c130c1d |
comparison
equal
deleted
inserted
replaced
| 45:8bc395c87c6f | 46:b7376319d25a |
|---|---|
| 64 include "private/db.php"; | 64 include "private/db.php"; |
| 65 | 65 |
| 66 $query = "CALL b_getBookInfo('$isbn', $loc)"; | 66 $query = "CALL b_getBookInfo('$isbn', $loc)"; |
| 67 //select Timestamp,Title,Author,Binding,DeweyDecimal,ImageURL,SalesRank,PublicationDate,Publisher,Genre1,Genre2,Genre3 from books where ISBN = '$isbn'"; | 67 //select Timestamp,Title,Author,Binding,DeweyDecimal,ImageURL,SalesRank,PublicationDate,Publisher,Genre1,Genre2,Genre3 from books where ISBN = '$isbn'"; |
| 68 //echo $query; | 68 //echo $query; |
| 69 $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); | 69 $res = my_query($query,'gbd1'); |
| 70 | 70 |
| 71 if ( mysqli_num_rows( $res ) > 0 ) | 71 if ( mysqli_num_rows( $res ) > 0 ) |
| 72 { | 72 { |
| 73 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); | 73 $rows=mysqli_fetch_array($res, MYSQLI_ASSOC); |
| 74 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop | 74 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop |
| 106 | 106 |
| 107 if($proceed == true) | 107 if($proceed == true) |
| 108 { | 108 { |
| 109 include "aws_signed_request.php"; | 109 include "aws_signed_request.php"; |
| 110 include_once "../../xml/doAmazonRequest.php"; | 110 include_once "../../xml/doAmazonRequest.php"; |
| 111 dl("nbd proceeding: $isbn\n"); | |
| 112 | 111 |
| 113 //book does not exist already so look up all the info from browse nodes.... | 112 //book does not exist already so look up all the info from browse nodes.... |
| 114 | 113 |
| 115 $Adefault=array( | 114 $Adefault=array( |
| 116 'language' =>'en', //what language to render the page in | 115 'language' =>'en', //what language to render the page in |
| 239 //HST added | 238 //HST added |
| 240 break; | 239 break; |
| 241 } | 240 } |
| 242 $queryG = "CALL b_addBrowseNode($key,\"$value\")"; //add the name value pair for genre to new table | 241 $queryG = "CALL b_addBrowseNode($key,\"$value\")"; //add the name value pair for genre to new table |
| 243 //echo $queryG; | 242 //echo $queryG; |
| 244 $resG = mysqli_query($link, $queryG); | 243 $resG = my_query($queryG,'gbd2'); |
| 245 | 244 |
| 246 switch ($loop) { | 245 switch ($loop) { |
| 247 case 1: | 246 case 1: |
| 248 $g1 = $key; | 247 $g1 = $key; |
| 249 break; | 248 break; |
| 267 | 266 |
| 268 $title = strtr($title, '"', "'"); | 267 $title = strtr($title, '"', "'"); |
| 269 $queryInsert = "CALL b_addNewBook(\"$isbn\",\"$title\", \"$author\",\"$binding\",\"$imageURL\", $dewey, $salesRank,$pubDate,\"$publisher\",$g1,$g2,$g3,$loc)"; | 268 $queryInsert = "CALL b_addNewBook(\"$isbn\",\"$title\", \"$author\",\"$binding\",\"$imageURL\", $dewey, $salesRank,$pubDate,\"$publisher\",$g1,$g2,$g3,$loc)"; |
| 270 //echo $queryInsert; | 269 //echo $queryInsert; |
| 271 | 270 |
| 272 $res = mysqli_query($link, $queryInsert); | 271 $res = my_query($queryInsert,'gbd3'); |
| 273 if (!$res) { | |
| 274 $err=mysqli_error( $link ); | |
| 275 mysqli_close($link); | |
| 276 dl("anb failed: $err, $pubDate, $g2, $publisher, $title\n"); | |
| 277 exit($err); | |
| 278 } | |
| 279 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop | 272 mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop |
| 280 | 273 |
| 281 | 274 |
| 282 $output .= "<ISBN>" . htmlspecialchars($isbn) . "</ISBN>"; | 275 $output .= "<ISBN>" . htmlspecialchars($isbn) . "</ISBN>"; |
| 283 $output .= "<Title>" . htmlspecialchars($title) . "</Title>"; | 276 $output .= "<Title>" . htmlspecialchars($title) . "</Title>"; |
