Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Question about SQL....
Re: Question about SQL.... [message #29224 is a reply to message #29222] Mon, 11 October 2010 23:32 Go to previous messageGo to previous message
unodgs is currently offline  unodgs
Messages: 1366
Registered: November 2005
Location: Poland
Ultimate Contributor

Try this:

struct MyFields
{
	VectorMap<String, Value> data;
	SqlId t;
	
	MyFields(const SqlId& table, const VectorMap<String, Value>& map)
	{
		data <<= map;
		t = table;
	}
	
	void FieldLayout(FieldOperator& f)
	{
		f.Table(~t);
		f
			(NAME			, data.Get("NAME"))
			(ADDRESS		, data.Get("ADDRESS"))
			(COUNTRY		, data.Get("COUNTRY"))
			(ZIP			, data.Get("ZIP"))
			(PHONE			, data.Get("PHONE"))
			(FAX			, data.Get("FAX"))
			(CELL			, data.Get("CELL"))
			(LICENSES		, data.Get("LICENSES"))
			(EXPIRATION		, data.Get("EXPIRATION"))
			(ACTIVATIONKEY	, data.Get("ACTIVATIONKEY"))
			(ACTIVATIONSENT	, data.Get("ACTIVATIONSENT"))
			(ACTIVATED		, data.Get("ACTIVATED"));
	}
	
	operator Fields() { return callback(this, &MyFields::FieldLayout); }
};

String eMail = data.Get("EMAIL");

SQL * Select(SqlAll()).From(USERS).Where(EMAIL == eMail);

MyFields fields(USERS, data);
	
if(SQL.Fetch())
{
	SQL * Update(fields).Where(EMAIL == eMail);
}
else
{
	SQL * Insert(fields)
		(EMAIL, eMail);
}
 
Read Message
Read Message
Read Message
Previous Topic: Always MySQL Link error
Next Topic: Sqlite schema fixes
Goto Forum:
  


Current Time: Thu May 09 08:56:08 CEST 2024

Total time taken to generate the page: 0.02937 seconds