Part-DB-legacy icon indicating copy to clipboard operation
Part-DB-legacy copied to clipboard

After update to 0.5.7: SQLSTATE[HY000]: General error: 1525 Incorrect TIMESTAMP value: '-1'

Open jsuelwald opened this issue 6 years ago • 1 comments

Hi,

i've updated an existing installation of PartDB to 0.5.7 and on /system_log.php this error occured:

Datenbankfehler: SQLSTATE[HY000]: General error: 1525 Incorrect TIMESTAMP value: '-1'

SQL-Query: SELECT COUNT(id) AS count from log WHERE level <= ? AND (datetime >= ?) ORDER BY log.datetime DESC

Parameter: Array ( [0] => 7 [1] => -1 )

jsuelwald avatar Oct 29 '19 14:10 jsuelwald

What Part-DB version has you used before? What MySQL/MariaDB server version are you using?

jbtronics avatar Oct 31 '19 12:10 jbtronics

Hi, I've experienced the same issue with PartDB 0.5.12 and MySQL 8.0.31. The problem seems to be that MySQL 8 doesn't accept the string value '-1' as a valid timestamp only if it isn't a string (I've verified this with an older MySQL version)

I've solved the (possible) issue(s) by editing the "filter for dates" of the getEntries() and getEntriesCount() functions in the lib/Log.php:

//Filter for dates if (($max_date != "") && ($max_date != "-1")) { $query .= " AND (datetime <= ?)"; $data[] = $max_date; }

if(($min_date != "") && ($min_date != "-1")) { $query .= " AND (datetime >= ?)"; $data[] = $min_date; }`

corn11 avatar Dec 01 '22 14:12 corn11

Should be fixed in Part-DB 0.5.13

jbtronics avatar Dec 18 '22 16:12 jbtronics