annotate mq.php @ 56:5f772caee9a7

try getting review from DB if throttled
author Charlie Root
date Fri, 07 Jun 2019 16:36:06 -0400
parents a04fc91bbd95
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
1 <?php
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
2 function my_query($q,$d='x')
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
3 {
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
4 global $link;
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
5 $res = mysqli_query($link, $q);
53
dd93cb4b77ad more debugging (too much for production), fallback to DB if getBookDetails is knocked back by Amazon
Charlie Root
parents: 49
diff changeset
6 include_once "dlog.php";
54
a04fc91bbd95 avoid warning on boolean
Charlie Root
parents: 53
diff changeset
7 dl("query from $d: ".is_bool($res) ? $res : mysqli_num_rows( $res )." $q\n");
47
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
8 if ($res) {
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
9 return $res;
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
10 }
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
11 else {
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
12 $err=mysqli_error( $link );
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
13 mysqli_close($link);
49
a67bf725e87b put both paths in include_path and depend on that
Charlie Root
parents: 47
diff changeset
14 include_once "dlog.php";
47
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
15 dl("query from $d failed: $q\n$err\n");
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
16 exit($err);
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
17 }
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
18 }
2a3943ced610 centralise db query even more
Charlie Root
parents:
diff changeset
19 ?>