How not to update some fields in table

Forum for posting problems using QxOrm library

How not to update some fields in table

Postby nickla » Tue Aug 21, 2012 8:14 pm

I dont want to update one field in table during qx::dao:update(). I found that third parameter is column array that will be updated. So, there are 2 questions:

How can i exclude field from update?

OR

How can i get list of fields if QxClass?
nickla
 
Posts: 52
Joined: Wed Jul 11, 2012 4:19 pm
Location: Russia

Re: How not to update some fields in table

Postby qxorm » Thu Aug 23, 2012 6:42 am

Hi,

I found that third parameter is column array that will be updated.

Yes here is the signature of qx::dao::update function :
QSqlError qx::dao::update (T & t, QSqlDatabase * pDatabase = NULL, const QStringList &columns = QStringList())
So if you provide a list of columns to the third parameter, the function will update only columns of your choice.

How can i exclude field from update ?

Using qx::dao::update function, you can't : you have to pass a list of columns to include to your query (and not to exclude).

How can i get list of fields if QxClass ?

You can retrieve a list of columns for a specific class using introspection engine of QxOrm library.
More details in the FAQ, here : http://www.qxorm.com/qxorm_en/faq.html#faq_190

This code could help you :
Code: Select all
QString IxClass::dumpClass() const
{
   QString sDump;
   sDump += "-- class '" + m_sKey + "' (name '" + m_sName + "', ";
   sDump += "description '" + m_sDescription + "', version '" + QString::number(m_lVersion) + "', ";
   sDump += "base class '" + (getBaseClass() ? getBaseClass()->getKey() : "") + "')\n";

   long lCount = (m_pDataMemberX ? m_pDataMemberX->count() : 0);
   sDump += "\t* list of registered properties (" + QString::number(lCount) + ")\n";
   if (m_pDataMemberX)
   {
      IxDataMember * pId = this->getId();
      for (long l = 0; l < lCount; l++)
      {
         IxDataMember * p = m_pDataMemberX->get(l); if (! p) { continue; }
         IxSqlRelation * pRelation = p->getSqlRelation();
         QString sInfos = p->getKey() + ((p == pId) ? QString(" (id)") : QString());
         sInfos += (pRelation ? (QString(" (") + pRelation->getDescription() + QString(")")) : QString());
         sDump += "\t\t" + sInfos + "\n";
      }
   }
   // etc...
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 6 guests