|
|
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 #19152 is a reply to message #19120] |
Sat, 15 November 2008 15:02 |
|
mirek
Messages: 13976 Registered: November 2005
|
Ultimate Member |
|
|
sergeynikitin wrote on Thu, 13 November 2008 05:26 |
What do you mean? What is the difference between SQL and sql?
|
I mean that SQL is global variable (well, technically, it is more comlicated, but it behaves just like global variable).
And the inherent problem with global variables is that they are problem in reentrant code.
void Sum(int id) {
return SQL % Select(SqlSum(MONEY)).From(TABLE).Where(ID == id);
}
void PrintSums() {
SQL * Select(NAME, MONEY_ID).From(TABLE);
while(SQL.Fetch())
Print(SQL[NAME], Sum(SQL[MONEY_ID]);
}
I have made this bug way too many times -> that is why I always have to warn about fetching from SQL.
Quote: |
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);
|
This corrent and in fact, you do not need to repeat
Sql sql(session);
because
Sql sql;
is the same as
Sql sql(SQL.GetSession());
There are two purposes for SQL - to serve as simple cursor for inster/delete/update and inline fetches AND to represent default global database connection so that you do not need to repeat 'session' all the time.
Just do not do explicit fetches from it, because while technically possible, it is a sure way how to shoot you leg:)
Mirek
|
|
|
|
|
How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
By: zsolt on Mon, 20 October 2008 14:20
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
By: zsolt on Mon, 20 October 2008 22:51
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
By: mirek on Sun, 02 November 2008 16:47
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
By: unodgs on Sun, 02 November 2008 19:09
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
By: unodgs on Sun, 02 November 2008 20:44
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
By: mirek on Sun, 02 November 2008 22:01
|
|
|
Re: How to display fields from different tables in one SQLArray
By: mirek on Sun, 02 November 2008 21:59
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
By: mirek on Wed, 12 November 2008 22:23
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
By: mirek on Sat, 15 November 2008 15:02
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
By: mirek on Sun, 02 November 2008 21:55
|
|
|
Re: How to display fields from different tables in one SQLArray
By: mr_ped on Fri, 20 March 2009 21:37
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
Re: How to display fields from different tables in one SQLArray
|
|
|
template + convert problem
|
|
|
Re: template + convert problem
By: Zbych on Sat, 19 September 2009 19:30
|
|
|
Re: template + convert problem
|
|
|
Re: template + convert problem
|
|
|
Re: template + convert problem
|
|
|
Re: template + convert problem
By: Zbych on Sun, 20 September 2009 15:47
|
|
|
Re: template + convert problem
|
|
|
Re: template + convert problem
|
Goto Forum:
Current Time: Sat May 11 07:34:18 CEST 2024
Total time taken to generate the page: 0.03588 seconds
|
|
|