Mercurial > hg > ywww
changeset 46:b7376319d25a
centralise db query even more
author | Charlie Root |
---|---|
date | Sun, 06 Jan 2019 12:15:42 -0500 |
parents | 8bc395c87c6f |
children | 2a3943ced610 |
files | php/read/getBookDetails.php php/read/getLeaderboard.php php/read/getLinkedBooks.php us/index.php xml/getAmazonInfo.php |
diffstat | 5 files changed, 17 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/php/read/getBookDetails.php Sun Jan 06 08:09:47 2019 -0500 +++ b/php/read/getBookDetails.php Sun Jan 06 12:15:42 2019 -0500 @@ -66,7 +66,7 @@ $query = "CALL b_getBookInfo('$isbn', $loc)"; //select Timestamp,Title,Author,Binding,DeweyDecimal,ImageURL,SalesRank,PublicationDate,Publisher,Genre1,Genre2,Genre3 from books where ISBN = '$isbn'"; //echo $query; - $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); + $res = my_query($query,'gbd1'); if ( mysqli_num_rows( $res ) > 0 ) { @@ -108,7 +108,6 @@ { include "aws_signed_request.php"; include_once "../../xml/doAmazonRequest.php"; - dl("nbd proceeding: $isbn\n"); //book does not exist already so look up all the info from browse nodes.... @@ -241,7 +240,7 @@ } $queryG = "CALL b_addBrowseNode($key,\"$value\")"; //add the name value pair for genre to new table //echo $queryG; - $resG = mysqli_query($link, $queryG); + $resG = my_query($queryG,'gbd2'); switch ($loop) { case 1: @@ -269,13 +268,7 @@ $queryInsert = "CALL b_addNewBook(\"$isbn\",\"$title\", \"$author\",\"$binding\",\"$imageURL\", $dewey, $salesRank,$pubDate,\"$publisher\",$g1,$g2,$g3,$loc)"; //echo $queryInsert; - $res = mysqli_query($link, $queryInsert); - if (!$res) { - $err=mysqli_error( $link ); - mysqli_close($link); - dl("anb failed: $err, $pubDate, $g2, $publisher, $title\n"); - exit($err); - } + $res = my_query($queryInsert,'gbd3'); mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop
--- a/php/read/getLeaderboard.php Sun Jan 06 08:09:47 2019 -0500 +++ b/php/read/getLeaderboard.php Sun Jan 06 12:15:42 2019 -0500 @@ -1,9 +1,9 @@ <?PHP -include "../../../private/db.php"; +include "private/db.php"; $query = "CALL b_getLeaderboard()"; -$results = mysqli_query($link, $query) or exit( mysqli_error( $link )); +$results = my_query( $query,'gl'); $output = ""; $output .= "<?xml version=\"1.0\"?>";
--- a/php/read/getLinkedBooks.php Sun Jan 06 08:09:47 2019 -0500 +++ b/php/read/getLinkedBooks.php Sun Jan 06 12:15:42 2019 -0500 @@ -1,4 +1,5 @@ <?PHP + if(!isset($ret)) { header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); @@ -7,6 +8,7 @@ header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache"); } + $linkedBooks = 0; include "similar.php"; @@ -23,20 +25,20 @@ $loc = 1; //default location is 1 } +include "private/db.php"; + if(isset($ret)) { - include "../../private/db.php"; $loc = $countryCode; //passed from index.php when googlebot is crawling } else { - include "../../../private/db.php"; $ret = 0; } $query = "CALL b_getLinksForISBN('$isbn',$loc)"; //echo $query; -$results = mysqli_query($link, $query) or exit( mysqli_error( $link )); +$results = my_query($query,'glb'); $output = "<?xml version=\"1.0\"?>"; $output .= "<results>";
--- a/us/index.php Sun Jan 06 08:09:47 2019 -0500 +++ b/us/index.php Sun Jan 06 12:15:42 2019 -0500 @@ -1,6 +1,8 @@ <?PHP include_once "ywww/dlog.php"; +dl("us\n"); session_start(); +dl("us sessoin\n"); function uniqueRand($n, $min = 0, $max = null) {
--- a/xml/getAmazonInfo.php Sun Jan 06 08:09:47 2019 -0500 +++ b/xml/getAmazonInfo.php Sun Jan 06 12:15:42 2019 -0500 @@ -251,8 +251,8 @@ } $queryG = "CALL b_addBrowseNode($key,\"$value\")"; //add the name value pair for genre to new table //echo $queryG; - include "../../private/db.php"; - $resG = mysqli_query($link, $queryG); + include "private/db.php"; + $resG = my_query($queryG,'gai0'); mysqli_close($link); switch ($loop) { @@ -311,22 +311,10 @@ $queryInsert = "CALL b_addNewBook(\"$searchparameterdata\",$title, $author,\"$binding\",\"$imageURL\", $dewey, $salesRank,$pubDate,$publisher,$g1,$g2,$g3,$loc)"; //echo $queryInsert; - $res = mysqli_query($link, $queryInsert); - if (!$res) { - $err=mysqli_error( $link ); - mysqli_close($link); - dl("anb failed: $queryInsert\n$err\n"); - exit($err); - } + $res = my_query($queryInsert,'gai1'); $queryInsertReviews = "CALL b_insertReviews(\"$searchparameterdata\",\"$review1\",\"$review2\",\"$review3\")"; if($review1 != "") { - $res = mysqli_query($link, $queryInsertReviews); - if (!$res) { - $err=mysqli_error( $link ); - mysqli_close($link); - dl("anr failed: $queryInsertReviews\n"); - exit($err); - } + $res = my_query($queryInsertReviews,'gai2'); } mysqli_close($link); //do not remove. reset is needed otherwise mysqli_fetch_array doesn't work after first loop } @@ -345,7 +333,7 @@ include "../../private/db.php"; $query = "CALL b_getBookInfo('$searchparameterdata', $loc)"; //echo $query; - $res = mysqli_query($link, $query) or exit( mysqli_error( $link )); + $res = my_query($query,'gai3'); $output = ""; $output .= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";