Skip to content

Mapper is unable to insert record without explicit values #394

@scrazzy

Description

@scrazzy

Hello,
I am experiencing this issue in projects where my table contains only columns with default values. E.g column ID is autoincrement, CREATED is currenttimestamp() and column DELETED is default 0. I have no need to insert any values to mapper, I just need to insert row. Even if I set this values in mapper to NULL, so $mapper->changed() is TRUE and then use $mapper->insert() or save(), mapper doesn't create record.
Only solution I found is to get DB connection and call $db->exec("INSERT INTO table VALUES(DEFAULT,DEFAULT,DEFAULT)") and then dig into PDO to get inserted ID with $db->pdo()->lastInsertId().
It could be very useful to be able insert such record with mapper directly and then continue with its functionality such as $mapper->_id etc.

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