sending null value to database.

sending null value to database.

TakumaTakuma Posts: 3Questions: 0Answers: 0
edited August 2013 in Editor
Hi,
is it possible to send null value to mysql database and not 0 ?
[code]
"label": "Label",
"name": "Name",
"default": null,
[/code]


When I do like above, my database recieves the value 0 and not NULL.

I tried it with
"default": "",
but same result.

Thank you.

Replies

  • tangerinetangerine Posts: 3,348Questions: 36Answers: 394
    edited August 2013
    I think that this is a characteristic of MySQL rather than a Datatables issue.

    Have you tried this (only from memory):
    1. Make NULL the field's default value in MySQL;
    2. When inserting new records, don't send that field anything.
  • TakumaTakuma Posts: 3Questions: 0Answers: 0
    I have tried it already. Doesn´t work.
  • allanallan Posts: 61,635Questions: 1Answers: 10,092 Site admin
    Is it an int type in the db? This SO post seems relevant: http://stackoverflow.com/questions/6918164/empty-string-inserting-a-zero-not-a-null

    You might need to use a set formatter if you are using the Editor PHP libraries: http://editor.datatables.net/docs/current/php/class-DataTables.Editor.Field.html#_setFormatter

    Allan
This discussion has been closed.