Page 1 of 1

How to set a value to NULL

PostPosted: Wed Jul 17, 2013 7:13 am
by vnuss
Hi everyone,

am using the version 1.22 of QxOrm (with Db MySql).

I have two tables where the relation (Foreign key) of them is nice to have.

If the case occurres that the relation is "nice to have", i want set the column value to NULL.

How can I implement this case.

Thanks in advance for help.

Re: How to set a value to NULL

PostPosted: Wed Jul 17, 2013 6:41 pm
by qxorm
Hi,

version 1.22 of QxOrm

This is an old version : I recommend to update to the last version.

i want set the column value to NULL

To put a NULL value into database, you have 3 possibilities :
* work with pointer (or smart pointer), and set the pointer to NULL before saving into database ;
* or use a QVariant type ;
* or use boost::optional (you must have at least QxOrm 1.2.4 for this feature).

Re: How to set a value to NULL

PostPosted: Thu Jul 18, 2013 7:52 am
by vnuss
Thanks a lot.
The solution with QVariant works fine for me.

Re: How to set a value to NULL

PostPosted: Fri Jul 19, 2013 9:30 am
by qxorm
The solution with QVariant works fine for me.

Great ;)