Add cover art database

Co-authored-by: Job Curtis <job.curtis@gmail.com>
Co-authored-by: Alex Cabal <alex@standardebooks.org>
This commit is contained in:
Mike Colagrosso 2023-12-28 16:38:39 -06:00 committed by Alex Cabal
parent 74f747df76
commit 6a5c05511a
92 changed files with 3174 additions and 146 deletions

View file

@ -1,6 +1,7 @@
<?
use Safe\DateTime;
use function Safe\preg_match;
use function Safe\posix_getpwuid;
class DbConnection{
private $_link = null;
@ -126,7 +127,7 @@ class DbConnection{
$done = true;
}
catch(\PDOException $ex){
if($ex->errorInfo[1] == 1213 && $deadlockRetries < 3){ // InnoDB deadlock, this is normal and happens occasionally. All we have to do is retry the query.
if(isset($ex->errorInfo) && $ex->errorInfo[1] == 1213 && $deadlockRetries < 3){ // InnoDB deadlock, this is normal and happens occasionally. All we have to do is retry the query.
$deadlockRetries++;
usleep(500000 * $deadlockRetries); // Give the deadlock some time to clear up. Start at .5 seconds
@ -188,12 +189,17 @@ class DbConnection{
$object = new $class();
for($i = 0; $i < $handle->columnCount(); $i++){
if($metadata[$i] === false){
continue;
}
if($row[$i] === null){
$object->{$metadata[$i]['name']} = null;
}
else{
switch($metadata[$i]['native_type']){
switch($metadata[$i]['native_type'] ?? null){
case 'DATETIME':
case 'TIMESTAMP':
$object->{$metadata[$i]['name']} = new DateTime($row[$i], new DateTimeZone('UTC'));
break;
@ -228,7 +234,7 @@ class DbConnection{
catch(\PDOException $ex){
// HY000 is thrown when there is no result set, e.g. for an update operation.
// If anything besides that is thrown, then send it up the stack
if($ex->errorInfo[0] != "HY000"){
if(!isset($ex->errorInfo) || $ex->errorInfo[0] != "HY000"){
throw $ex;
}
}