How to set a value to NULL

Forum for posting problems using QxOrm library

How to set a value to NULL

Postby vnuss » Wed Jul 17, 2013 7:13 am

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.
vnuss
 
Posts: 2
Joined: Wed Jul 17, 2013 7:01 am

Re: How to set a value to NULL

Postby qxorm » Wed Jul 17, 2013 6:41 pm

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).
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am

Re: How to set a value to NULL

Postby vnuss » Thu Jul 18, 2013 7:52 am

Thanks a lot.
The solution with QVariant works fine for me.
vnuss
 
Posts: 2
Joined: Wed Jul 17, 2013 7:01 am

Re: How to set a value to NULL

Postby qxorm » Fri Jul 19, 2013 9:30 am

The solution with QVariant works fine for me.

Great ;)
qxorm
Site Admin
 
Posts: 481
Joined: Mon Apr 12, 2010 7:45 am


Return to QxOrm - Help

Who is online

Users browsing this forum: No registered users and 7 guests

cron