Пример #1
0
QString PlayGroupDBStorage::GetWhereClause(MSqlBindings &bindings) const
{
    QString nameTag(":WHERENAME");
    QString query("name = " + nameTag);

    bindings.insert(nameTag, parent.getName());

    return query;
}
Пример #2
0
/**
	Convert entity to xml dom document
   	\param preferAttrib - if true (default) generate attributes, else elements
	... <attr name="atrname" val="atrVal"/> ... vs <atrname>atrVal<atrname/>
	\param skipEmpty	- if true (default) skip empty values
	\param upperCase	- if true - uppercase all tags (default is false)
	\return Dom document reference
*/
QDomDocument& RecordBase::GetDom
(
	bool preferAttrib,
	bool skipEmpty,
	bool upperCase
)
{
	QString idTag(kTagID);
	QString attrTag(kTagAttr);
	QString nameTag(kTagName);
	QString valTag(kTagValue);
	QString entName(EntityName());

	if (upperCase) 
	{
		entName = entName.toUpper();
		idTag   = idTag.toUpper();
		attrTag = attrTag.toUpper();
		nameTag = nameTag.toUpper();
		valTag  = valTag.toUpper();
	}

	if (_xmlDoc)
		delete _xmlDoc;

	QDomElement root;

	_xmlDoc = new QDomDocument;
	
	root = _xmlDoc->createElement(entName);
    _xmlDoc->appendChild(root);
	// append id attrib to root

	root.setAttribute(idTag, Key());
	// enumerate fields
	for (quint32 i(1); i < Count(); i++) 
	{
		QString name = Field(i);
		QString v = Value(i).toString().trimmed();
		
		if (v.length() > 0 || (v.length() == 0 && !skipEmpty)) 
		{
			if (upperCase) 
				name = name.toUpper();

			if (preferAttrib) 
			{
				QDomElement elem = _xmlDoc->createElement(attrTag);
				elem.setAttribute(nameTag, name);
				elem.setAttribute(valTag , v);
				root.appendChild (elem);
			}
			else // use elements
			{
				
				QDomElement elem = _xmlDoc->createElement(name);
				QDomText txt  = _xmlDoc->createTextNode(v);
				elem.appendChild(txt);
				root.appendChild(elem);
			}
		}
	}

	return *_xmlDoc;
}