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 » How to display fields from different tables in one SQLArray
Re: How to display fields from different tables in one SQLArray [message #19120 is a reply to message #19110] Thu, 13 November 2008 11:26 Go to previous messageGo to previous message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

luzr wrote on Thu, 13 November 2008 00:23

sergeynikitin wrote on Sun, 02 November 2008 16:09

By the way, I have decided to how to display related fields from other tables by using SqlArray.

[code]
struct ConvCompany : Convert
{
Value Format(const Value &q) const
{
SQL * Select(COM_NAME).From(COMPANY).Where(COM_ID == q);
String company;
if(SQL.Fetch())
company = SQL[COM_NAME];
else
company = "";
return q.IsNull() ? Null : company;
}
};




WARNING: Fetching from SQL ("SQL.Fetch()") is NOT RECOMMENDED (based on expriences:)

It is way too simple to call something in the fetch loop which will issue different SQL statment through SQL.

Use "Sql sql; sql * Select....; sql.Fetch()" instead.






What do you mean? What is the difference between SQL and sql?
In my app I use this initialization code:
	MySqlSession session;
	if(!session.Connect(app.mysql_username, app.mysql_password, app.mysql_database, app.mysql_server)) {
		printf("Can't connect with MySql\n");
		PromptOK(t_("Can't connect with MySql"));
		return;
	}
	mysql_set_character_set(session, "utf8");
	
	SQL = session;
	Sql sql(session);

If you can - I want a short comment about the differences of my decision and your.

Yes. perhaps this is the best solution - to write complex pieces by hands.

By the way, thanks for the complex example.


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: DBF crash error while writing record
Next Topic: PATCH/BUGFIX Oracle asTable Failure - Solution
Goto Forum:
  


Current Time: Sat May 11 12:10:27 CEST 2024

Total time taken to generate the page: 0.03884 seconds