Part-DB / Part-DB-legacy

[LEGACY Version] Open Source Electronic Parts Database using PHP and MySQL
GNU General Public License v2.0
158 stars 35 forks source link

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

Closed jsuelwald closed 1 year ago

jsuelwald commented 4 years ago

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 )

jbtronics commented 4 years ago

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

corn11 commented 1 year ago

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; }`

jbtronics commented 1 year ago

Should be fixed in Part-DB 0.5.13