Skip to content

SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value #29

@kocheskid

Description

@kocheskid

First I want to mention that I'm on PHP 7.2.13, now the problem:

  • I have webstore that logged users and guest users are allowed to add items to cart. I'm using DatabaseStorage, when logged in user adds item in the cart, the module creates record in the cart table with sessionId : {logged_in_user_id} Ex: 1, and when Guest user adds item in the cart, the module creates record in the cart table with sessionId : {session_id} Ex: 77g9t9t5u5qdvrogoi4j0muiam , ONLY when both of these record types exists in the Cart Table, when you try to delete the last item in the cart from the LOGGED User (sessionId: 1), it throws the error:

SQLSTATE[22007]: Invalid datetime format: 1292 Truncated incorrect DOUBLE value: '77g9t9t5u5qdvrogoi4j0muiam'
The SQL being executed was: DELETE FROM cart WHERE sessionId=1

I resolve this by chaning this: (DatabaseStorage.php Line:132)
$command->delete($this->table, [$this->idField => $identifier]);

to this:
$command->delete($this->table, [$this->idField => (string)$identifier]);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions