From 0b763bd132abedbaa9c08900b64c8144e90a675b Mon Sep 17 00:00:00 2001 From: acanas Date: Mon, 8 Mar 2021 09:48:13 +0100 Subject: [PATCH] Version 20.45.2: Mar 08, 2021 Countries database table renamed. --- sql/swad.sql | 112 +++++++++++------------ swad_changelog.h | 14 +-- swad_country.c | 125 ++++++++++++++++---------- swad_country_config.c | 7 +- swad_database.c | 204 +++++++++++++++++++++--------------------- swad_institution.c | 8 +- swad_search.c | 87 +++++++++--------- swad_user.c | 12 +-- 8 files changed, 303 insertions(+), 266 deletions(-) diff --git a/sql/swad.sql b/sql/swad.sql index 531b3484..b5eccecb 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -165,26 +165,6 @@ CREATE TABLE IF NOT EXISTS buildings ( UNIQUE INDEX(BldCod), INDEX(CtrCod)); -- --- Table ctr_centers: centers (faculties, schools...) --- -CREATE TABLE IF NOT EXISTS ctr_centers ( - CtrCod INT NOT NULL AUTO_INCREMENT, - InsCod INT NOT NULL, - PlcCod INT NOT NULL DEFAULT -1, - Status TINYINT NOT NULL DEFAULT 0, - RequesterUsrCod INT NOT NULL DEFAULT -1, - Latitude DOUBLE PRECISION NOT NULL DEFAULT 0, - Longitude DOUBLE PRECISION NOT NULL DEFAULT 0, - Altitude DOUBLE PRECISION NOT NULL DEFAULT 0, - ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL, - FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL, - WWW VARCHAR(255) NOT NULL, - PhotoAttribution TEXT NOT NULL, - UNIQUE INDEX(CtrCod), - INDEX(InsCod), - INDEX(PlcCod), - INDEX(Status)); --- -- Table chat: stores number of users in each chat room (this table is not used now) -- CREATE TABLE IF NOT EXISTS chat ( @@ -224,42 +204,6 @@ CREATE TABLE IF NOT EXISTS connected ( INDEX(RoleInLastCrs), INDEX(LastCrsCod)); -- --- Table countries: stores the countries --- -CREATE TABLE IF NOT EXISTS countries ( - CtyCod INT NOT NULL, - Alpha2 CHAR(2) NOT NULL, - MapAttribution TEXT NOT NULL, - Name_ca VARCHAR(767) NOT NULL, - Name_de VARCHAR(767) NOT NULL, - Name_en VARCHAR(767) NOT NULL, - Name_es VARCHAR(767) NOT NULL, - Name_fr VARCHAR(767) NOT NULL, - Name_gn VARCHAR(767) NOT NULL, - Name_it VARCHAR(767) NOT NULL, - Name_pl VARCHAR(767) NOT NULL, - Name_pt VARCHAR(767) NOT NULL, - WWW_ca VARCHAR(255) NOT NULL, - WWW_de VARCHAR(255) NOT NULL, - WWW_en VARCHAR(255) NOT NULL, - WWW_es VARCHAR(255) NOT NULL, - WWW_fr VARCHAR(255) NOT NULL, - WWW_gn VARCHAR(255) NOT NULL, - WWW_it VARCHAR(255) NOT NULL, - WWW_pl VARCHAR(255) NOT NULL, - WWW_pt VARCHAR(255) NOT NULL, - UNIQUE INDEX(CtyCod), - UNIQUE INDEX(Alpha2), - INDEX(Name_ca), - INDEX(Name_de), - INDEX(Name_en), - INDEX(Name_es), - INDEX(Name_fr), - INDEX(Name_gn), - INDEX(Name_it), - INDEX(Name_pl), - INDEX(Name_pt)); --- -- Table crs_courses: stores the courses/subjects -- CREATE TABLE IF NOT EXISTS crs_courses ( @@ -409,6 +353,62 @@ CREATE TABLE IF NOT EXISTS crs_usr_requests ( UNIQUE INDEX(CrsCod,UsrCod), INDEX(UsrCod)); -- +-- Table ctr_centers: centers (faculties, schools...) +-- +CREATE TABLE IF NOT EXISTS ctr_centers ( + CtrCod INT NOT NULL AUTO_INCREMENT, + InsCod INT NOT NULL, + PlcCod INT NOT NULL DEFAULT -1, + Status TINYINT NOT NULL DEFAULT 0, + RequesterUsrCod INT NOT NULL DEFAULT -1, + Latitude DOUBLE PRECISION NOT NULL DEFAULT 0, + Longitude DOUBLE PRECISION NOT NULL DEFAULT 0, + Altitude DOUBLE PRECISION NOT NULL DEFAULT 0, + ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL, + FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL, + WWW VARCHAR(255) NOT NULL, + PhotoAttribution TEXT NOT NULL, + UNIQUE INDEX(CtrCod), + INDEX(InsCod), + INDEX(PlcCod), + INDEX(Status)); +-- +-- Table cty_countrs: stores the countries +-- +CREATE TABLE IF NOT EXISTS cty_countrs ( + CtyCod INT NOT NULL, + Alpha2 CHAR(2) NOT NULL, + MapAttribution TEXT NOT NULL, + Name_ca VARCHAR(767) NOT NULL, + Name_de VARCHAR(767) NOT NULL, + Name_en VARCHAR(767) NOT NULL, + Name_es VARCHAR(767) NOT NULL, + Name_fr VARCHAR(767) NOT NULL, + Name_gn VARCHAR(767) NOT NULL, + Name_it VARCHAR(767) NOT NULL, + Name_pl VARCHAR(767) NOT NULL, + Name_pt VARCHAR(767) NOT NULL, + WWW_ca VARCHAR(255) NOT NULL, + WWW_de VARCHAR(255) NOT NULL, + WWW_en VARCHAR(255) NOT NULL, + WWW_es VARCHAR(255) NOT NULL, + WWW_fr VARCHAR(255) NOT NULL, + WWW_gn VARCHAR(255) NOT NULL, + WWW_it VARCHAR(255) NOT NULL, + WWW_pl VARCHAR(255) NOT NULL, + WWW_pt VARCHAR(255) NOT NULL, + UNIQUE INDEX(CtyCod), + UNIQUE INDEX(Alpha2), + INDEX(Name_ca), + INDEX(Name_de), + INDEX(Name_en), + INDEX(Name_es), + INDEX(Name_fr), + INDEX(Name_gn), + INDEX(Name_it), + INDEX(Name_pl), + INDEX(Name_pt)); +-- -- Table debug: used for debugging purposes -- CREATE TABLE IF NOT EXISTS debug ( diff --git a/swad_changelog.h b/swad_changelog.h index a1fa3b2d..5b7d35fb 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -600,17 +600,21 @@ TODO: Salvador Romero Cort TODO: FIX BUG, URGENT! En las fechas como parámetro Dat_WriteParamsIniEndDates(), por ejemplo al cambiar el color de la gráfica de accesos por día y hora, no se respeta la zona horaria. */ -#define Log_PLATFORM_VERSION "SWAD 20.45.1 (2021-03-07)" +#define Log_PLATFORM_VERSION "SWAD 20.45.2 (2021-03-08)" #define CSS_FILE "swad20.45.css" #define JS_FILE "swad20.6.2.js" /* - Version 20.45.1: Mar 06, 2021 Institutions database table renamed. (307120 lines) +TODO: Rename CENTRE to CENTER in help wiki. + + Version 20.45.2: Mar 08, 2021 Institutions database table renamed. (307156 lines) + 1 change necessary in database: +RENAME TABLE countries TO cty_countrs; + + Version 20.45.1: Mar 07, 2021 Institutions database table renamed. (307120 lines) 1 change necessary in database: RENAME TABLE institutions TO ins_instits; -TODO: Rename CENTRE to CENTER in help wiki. - - Version 20.45: Mar 06, 2021 Centers database table renamed. + Version 20.45: Mar 07, 2021 Centers database table renamed. All variables and files related to centers renamed. (307106 lines) 1 change necessary in database: RENAME TABLE centres TO ctr_centers; diff --git a/swad_country.c b/swad_country.c index 47a2ec93..2d8df6f5 100644 --- a/swad_country.c +++ b/swad_country.c @@ -129,11 +129,11 @@ void Cty_SeeCtyWithPendingInss (void) "SELECT ins_instits.CtyCod," "COUNT(*)" " FROM ins_instits," - "countries" + "cty_countrs" " WHERE (ins_instits.Status & %u)<>0" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" " GROUP BY ins_instits.CtyCod" - " ORDER BY countries.Name_%s", + " ORDER BY cty_countrs.Name_%s", (unsigned) Ins_STATUS_BIT_PENDING, Lan_STR_LANG_ID[Gbl.Prefs.Language]); break; @@ -760,8 +760,11 @@ void Cty_GetBasicListOfCountries (void) /***** Get countries from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get countries", - "SELECT CtyCod,Alpha2,Name_%s" - " FROM countries ORDER BY Name_%s", + "SELECT CtyCod," // row[0] + "Alpha2," // row[1] + "Name_%s" // row[2] + " FROM cty_countrs" + " ORDER BY Name_%s", Lan_STR_LANG_ID[Gbl.Prefs.Language], Lan_STR_LANG_ID[Gbl.Prefs.Language]); if (NumRows) // Countries found... @@ -850,12 +853,12 @@ void Cty_GetFullListOfCountries (void) Lan <= (Lan_Language_t) Lan_NUM_LANGUAGES; Lan++) { - snprintf (StrField,sizeof (StrField),"countries.Name_%s,",Lan_STR_LANG_ID[Lan]); + snprintf (StrField,sizeof (StrField),"cty_countrs.Name_%s,",Lan_STR_LANG_ID[Lan]); Str_Concat (SubQueryNam1,StrField,sizeof (SubQueryNam1) - 1); snprintf (StrField,sizeof (StrField),"Name_%s,",Lan_STR_LANG_ID[Lan]); Str_Concat (SubQueryNam2,StrField,sizeof (SubQueryNam2) - 1); - snprintf (StrField,sizeof (StrField),"countries.WWW_%s,",Lan_STR_LANG_ID[Lan]); + snprintf (StrField,sizeof (StrField),"cty_countrs.WWW_%s,",Lan_STR_LANG_ID[Lan]); Str_Concat (SubQueryWWW1,StrField,sizeof (SubQueryWWW1) - 1); snprintf (StrField,sizeof (StrField),"WWW_%s,",Lan_STR_LANG_ID[Lan]); Str_Concat (SubQueryWWW2,StrField,sizeof (SubQueryWWW2) - 1); @@ -868,14 +871,22 @@ void Cty_GetFullListOfCountries (void) /* Query database */ NumRows = DB_QuerySELECT (&mysql_res,"can not get countries", - "(SELECT countries.CtyCod,countries.Alpha2," - "%s%sCOUNT(*) AS NumUsrs" - " FROM countries,usr_data" - " WHERE countries.CtyCod=usr_data.CtyCod" - " GROUP BY countries.CtyCod)" + "(SELECT cty_countrs.CtyCod," // row[0] + "cty_countrs.Alpha2," // row[1] + "%s" // row[...] + "%s" // row[...] + "COUNT(*) AS NumUsrs" // row[...] + " FROM cty_countrs," + "usr_data" + " WHERE cty_countrs.CtyCod=usr_data.CtyCod" + " GROUP BY cty_countrs.CtyCod)" " UNION " - "(SELECT CtyCod,Alpha2,%s%s0 AS NumUsrs" - " FROM countries" + "(SELECT CtyCod," // row[0] + "Alpha2," // row[1] + "%s" // row[...] + "%s" // row[...] + "0 AS NumUsrs" // row[...] + " FROM cty_countrs" " WHERE CtyCod NOT IN" " (SELECT DISTINCT CtyCod FROM usr_data))" " ORDER BY %s", @@ -958,12 +969,14 @@ void Cty_WriteSelectorOfCountry (void) "[%s]",Txt_Country); /***** Get countries from database *****/ - NumCtys = (unsigned) DB_QuerySELECT (&mysql_res,"can not get countries", - "SELECT DISTINCT CtyCod,Name_%s" - " FROM countries" - " ORDER BY countries.Name_%s", - Lan_STR_LANG_ID[Gbl.Prefs.Language], - Lan_STR_LANG_ID[Gbl.Prefs.Language]); + NumCtys = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get countries", + "SELECT DISTINCT CtyCod," // row[0] + "Name_%s" // row[1] + " FROM cty_countrs" + " ORDER BY Name_%s", + Lan_STR_LANG_ID[Gbl.Prefs.Language], + Lan_STR_LANG_ID[Gbl.Prefs.Language]); /***** List countries *****/ for (NumCty = 0; @@ -1066,8 +1079,10 @@ bool Cty_GetDataOfCountryByCod (struct Cty_Countr *Cty) /***** Get data of a country from database *****/ NumRows = DB_QuerySELECT (&mysql_res,"can not get data of a country", - "SELECT Alpha2,Name_%s,WWW_%s" - " FROM countries" + "SELECT Alpha2," // row[0] + "Name_%s," // row[1] + "WWW_%s" // row[2] + " FROM cty_countrs" " WHERE CtyCod='%03ld'", Lan_STR_LANG_ID[Gbl.Prefs.Language], Lan_STR_LANG_ID[Gbl.Prefs.Language], @@ -1137,7 +1152,9 @@ void Cty_GetCountryName (long CtyCod,Lan_Language_t Language, Gbl.Cache.CountryName.Language = Language; if (DB_QuerySELECT (&mysql_res,"can not get the name of a country", - "SELECT Name_%s FROM countries WHERE CtyCod='%03ld'", + "SELECT Name_%s" // row[0] + " FROM cty_countrs" + " WHERE CtyCod='%03ld'", Lan_STR_LANG_ID[Language],CtyCod)) // Country found... { /* Get row */ @@ -1359,7 +1376,8 @@ void Cty_RemoveCountry (void) /***** Remove country *****/ DB_QueryDELETE ("can not remove a country", - "DELETE FROM countries WHERE CtyCod='%03ld'", + "DELETE FROM cty_countrs" + " WHERE CtyCod='%03ld'", Cty_EditingCty->CtyCod); /***** Flush cache *****/ @@ -1457,7 +1475,8 @@ static bool Cty_CheckIfNumericCountryCodeExists (long CtyCod) /***** Get number of countries with a name from database *****/ return (DB_QueryCOUNT ("can not check if the numeric code" " of a country already existed", - "SELECT COUNT(*) FROM countries" + "SELECT COUNT(*)" + " FROM cty_countrs" " WHERE CtyCod='%03ld'", CtyCod) != 0); } @@ -1471,7 +1490,8 @@ static bool Cty_CheckIfAlpha2CountryCodeExists (const char Alpha2[2 + 1]) /***** Get number of countries with a name from database *****/ return (DB_QueryCOUNT ("can not check if the alphabetic code" " of a country already existed", - "SELECT COUNT(*) FROM countries" + "SELECT COUNT(*)" + " FROM cty_countrs" " WHERE Alpha2='%s'", Alpha2) != 0); } @@ -1487,9 +1507,12 @@ static bool Cty_CheckIfCountryNameExists (Lan_Language_t Language,const char *Na /***** Get number of countries with a name from database *****/ return (DB_QueryCOUNT ("can not check if the name" " of a country already existed", - "SELECT COUNT(*) FROM countries" - " WHERE Name_%s='%s' AND CtyCod<>'%03ld'", - Lan_STR_LANG_ID[Language],Name,CtyCod) != 0); + "SELECT COUNT(*)" + " FROM cty_countrs" + " WHERE Name_%s='%s'" + " AND CtyCod<>'%03ld'", + Lan_STR_LANG_ID[Language],Name, + CtyCod) != 0); } /*****************************************************************************/ @@ -1500,8 +1523,11 @@ static void Cty_UpdateCtyNameDB (long CtyCod,const char *FieldName,const char *N { /***** Update country changing old name by new name */ DB_QueryUPDATE ("can not update the name of a country", - "UPDATE countries SET %s='%s' WHERE CtyCod='%03ld'", - FieldName,NewCtyName,CtyCod); + "UPDATE cty_countrs" + " SET %s='%s'" + " WHERE CtyCod='%03ld'", + FieldName,NewCtyName, + CtyCod); /***** Flush cache *****/ Cty_FlushCacheCountryName (); @@ -1535,7 +1561,8 @@ void Cty_ChangeCtyWWW (void) /***** Update the table changing old WWW by new WWW *****/ DB_QueryUPDATE ("can not update the web of a country", - "UPDATE countries SET WWW_%s='%s'" + "UPDATE cty_countrs" + " SET WWW_%s='%s'" " WHERE CtyCod='%03ld'", Lan_STR_LANG_ID[Language],NewWWW,Cty_EditingCty->CtyCod); Str_Copy (Cty_EditingCty->WWW[Language],NewWWW, @@ -1866,7 +1893,7 @@ static void Cty_CreateCountry (void) Str_Concat (SubQueryWWW2,"'",sizeof (SubQueryWWW2) - 1); } DB_QueryINSERT ("can not create country", - "INSERT INTO countries" + "INSERT INTO cty_countrs" " (CtyCod,Alpha2,MapAttribution%s%s)" " VALUES" " ('%03ld','%s',''%s%s)", @@ -1888,7 +1915,7 @@ unsigned Cty_GetCachedNumCtysInSys (void) FigCch_UNSIGNED,&NumCtys)) { /***** Get current number of countries from database and update cache *****/ - NumCtys = (unsigned) DB_GetNumRowsTable ("countries"); + NumCtys = (unsigned) DB_GetNumRowsTable ("cty_countrs"); FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtys); } @@ -1911,10 +1938,10 @@ unsigned Cty_GetCachedNumCtysWithInss (void) /***** Get current number of countries with institutions from cache *****/ NumCtysWithInss = (unsigned) DB_QueryCOUNT ("can not get number of countries with institutions", - "SELECT COUNT(DISTINCT countries.CtyCod)" - " FROM countries," + "SELECT COUNT(DISTINCT cty_countrs.CtyCod)" + " FROM cty_countrs," "ins_instits" - " WHERE countries.CtyCod=ins_instits.CtyCod"); + " WHERE cty_countrs.CtyCod=ins_instits.CtyCod"); FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_INSS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtysWithInss); } @@ -1937,11 +1964,11 @@ unsigned Cty_GetCachedNumCtysWithCtrs (void) /***** Get current number of countries with centers from database and update cache *****/ NumCtysWithCtrs = (unsigned) DB_QueryCOUNT ("can not get number of countries with centers", - "SELECT COUNT(DISTINCT countries.CtyCod)" - " FROM countries," + "SELECT COUNT(DISTINCT cty_countrs.CtyCod)" + " FROM cty_countrs," "ins_instits," "ctr_centers" - " WHERE countries.CtyCod=ins_instits.CtyCod" + " WHERE cty_countrs.CtyCod=ins_instits.CtyCod" " AND ins_instits.InsCod=ctr_centers.InsCod"); FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_CTRS,Hie_Lvl_SYS,-1L, FigCch_UNSIGNED,&NumCtysWithCtrs); @@ -1963,12 +1990,12 @@ unsigned Cty_GetCachedNumCtysWithDegs (void) { NumCtysWithDegs = (unsigned) DB_QueryCOUNT ("can not get number of countries with degrees", - "SELECT COUNT(DISTINCT countries.CtyCod)" - " FROM countries," + "SELECT COUNT(DISTINCT cty_countrs.CtyCod)" + " FROM cty_countrs," "ins_instits," "ctr_centers," "deg_degrees" - " WHERE countries.CtyCod=ins_instits.CtyCod" + " WHERE cty_countrs.CtyCod=ins_instits.CtyCod" " AND ins_instits.InsCod=ctr_centers.InsCod" " AND ctr_centers.CtrCod=deg_degrees.CtrCod"); FigCch_UpdateFigureIntoCache (FigCch_NUM_CTYS_WITH_DEGS,Hie_Lvl_SYS,-1L, @@ -1993,13 +2020,13 @@ unsigned Cty_GetCachedNumCtysWithCrss (void) /***** Get current number of countries with courses from database and update cache *****/ NumCtysWithCrss = (unsigned) DB_QueryCOUNT ("can not get number of countries with courses", - "SELECT COUNT(DISTINCT countries.CtyCod)" - " FROM countries," + "SELECT COUNT(DISTINCT cty_countrs.CtyCod)" + " FROM cty_countrs," "ins_instits," "ctr_centers," "deg_degrees," "crs_courses" - " WHERE countries.CtyCod=ins_instits.CtyCod" + " WHERE cty_countrs.CtyCod=ins_instits.CtyCod" " AND ins_instits.InsCod=ctr_centers.InsCod" " AND ctr_centers.CtrCod=deg_degrees.CtrCod" " AND deg_degrees.DegCod=crs_courses.DegCod"); @@ -2032,14 +2059,14 @@ unsigned Cty_GetCachedNumCtysWithUsrs (Rol_Role_t Role,const char *SubQuery, /***** Get current number of countries with users from database and update cache *****/ NumCtysWithUsrs = (unsigned) DB_QueryCOUNT ("can not get number of countries with users", - "SELECT COUNT(DISTINCT countries.CtyCod)" - " FROM countries," + "SELECT COUNT(DISTINCT cty_countrs.CtyCod)" + " FROM cty_countrs," "ins_instits," "ctr_centers," "deg_degrees," "crs_courses," "crs_usr" - " WHERE %scountries.CtyCod=ins_instits.CtyCod" + " WHERE %scty_countrs.CtyCod=ins_instits.CtyCod" " AND ins_instits.InsCod=ctr_centers.InsCod" " AND ctr_centers.CtrCod=deg_degrees.CtrCod" " AND deg_degrees.DegCod=crs_courses.DegCod" diff --git a/swad_country_config.c b/swad_country_config.c index a5d4534f..80a1afbb 100644 --- a/swad_country_config.c +++ b/swad_country_config.c @@ -583,7 +583,9 @@ static void CtyCfg_GetMapAttr (long CtyCod,char **MapAttribution) /***** Get photo attribution from database *****/ if (DB_QuerySELECT (&mysql_res,"can not get photo attribution", - "SELECT MapAttribution FROM countries WHERE CtyCod=%ld", + "SELECT MapAttribution" + " FROM cty_countrs" + " WHERE CtyCod=%ld", CtyCod)) { /* Get row */ @@ -631,7 +633,8 @@ void CtyCfg_ChangeCtyMapAttr (void) /***** Update the table changing old attribution by new attribution *****/ DB_QueryUPDATE ("can not update the map attribution of a country", - "UPDATE countries SET MapAttribution='%s'" + "UPDATE cty_countrs" + " SET MapAttribution='%s'" " WHERE CtyCod='%03ld'", NewMapAttribution,Gbl.Hierarchy.Cty.CtyCod); diff --git a/swad_database.c b/swad_database.c index c079a6b7..fd959888 100644 --- a/swad_database.c +++ b/swad_database.c @@ -420,45 +420,6 @@ mysql> DESCRIBE buildings; "UNIQUE INDEX(BldCod)," "INDEX(CtrCod))"); - /***** Table ctr_centers *****/ -/* -mysql> DESCRIBE ctr_centers; -+------------------+---------------+------+-----+---------+----------------+ -| Field | Type | Null | Key | Default | Extra | -+------------------+---------------+------+-----+---------+----------------+ -| CtrCod | int(11) | NO | PRI | NULL | auto_increment | -| InsCod | int(11) | NO | MUL | NULL | | -| PlcCod | int(11) | NO | MUL | -1 | | -| Status | tinyint(4) | NO | MUL | 0 | | -| RequesterUsrCod | int(11) | NO | | -1 | | -| Latitude | double | NO | | 0 | | -| Longitude | double | NO | | 0 | | -| Altitude | double | NO | | 0 | | -| ShortName | varchar(511) | NO | | NULL | | -| FullName | varchar(2047) | NO | | NULL | | -| WWW | varchar(255) | NO | | NULL | | -| PhotoAttribution | text | NO | | NULL | | -+------------------+---------------+------+-----+---------+----------------+ -12 rows in set (0.00 sec) -*/ - DB_CreateTable ("CREATE TABLE IF NOT EXISTS ctr_centers (" - "CtrCod INT NOT NULL AUTO_INCREMENT," - "InsCod INT NOT NULL," - "PlcCod INT NOT NULL," - "Status TINYINT NOT NULL DEFAULT 0," - "RequesterUsrCod INT NOT NULL DEFAULT -1," - "Latitude DOUBLE PRECISION NOT NULL DEFAULT 0," - "Longitude DOUBLE PRECISION NOT NULL DEFAULT 0," - "Altitude DOUBLE PRECISION NOT NULL DEFAULT 0," - "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_SHRT_NAME - "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_FULL_NAME - "WWW VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW - "PhotoAttribution TEXT NOT NULL," // Med_MAX_BYTES_ATTRIBUTION - "UNIQUE INDEX(CtrCod)," - "INDEX(InsCod)," - "INDEX(PlcCod)," - "INDEX(Status))"); - /***** Table chat *****/ /* mysql> DESCRIBE chat; @@ -541,69 +502,6 @@ mysql> DESCRIBE connected; "INDEX(RoleInLastCrs)," "INDEX(LastCrsCod))"); - /***** Table countries *****/ -/* -mysql> DESCRIBE countries; -+----------------+--------------+------+-----+---------+-------+ -| Field | Type | Null | Key | Default | Extra | -+----------------+--------------+------+-----+---------+-------+ -| CtyCod | int(11) | NO | PRI | NULL | | -| Alpha2 | char(2) | NO | UNI | NULL | | -| MapAttribution | text | NO | | NULL | | -| Name_ca | varchar(767) | NO | MUL | NULL | | -| Name_de | varchar(767) | NO | MUL | NULL | | -| Name_en | varchar(767) | NO | MUL | NULL | | -| Name_es | varchar(767) | NO | MUL | NULL | | -| Name_fr | varchar(767) | NO | MUL | NULL | | -| Name_gn | varchar(767) | NO | MUL | NULL | | -| Name_it | varchar(767) | NO | MUL | NULL | | -| Name_pl | varchar(767) | NO | MUL | NULL | | -| Name_pt | varchar(767) | NO | MUL | NULL | | -| WWW_ca | varchar(255) | NO | | NULL | | -| WWW_de | varchar(255) | NO | | NULL | | -| WWW_en | varchar(255) | NO | | NULL | | -| WWW_es | varchar(255) | NO | | NULL | | -| WWW_fr | varchar(255) | NO | | NULL | | -| WWW_gn | varchar(255) | NO | | NULL | | -| WWW_it | varchar(255) | NO | | NULL | | -| WWW_pl | varchar(255) | NO | | NULL | | -| WWW_pt | varchar(255) | NO | | NULL | | -+----------------+--------------+------+-----+---------+-------+ -21 rows in set (0,00 sec) -*/ - DB_CreateTable ("CREATE TABLE IF NOT EXISTS countries (" - "CtyCod INT NOT NULL," - "Alpha2 CHAR(2) NOT NULL," - "MapAttribution TEXT NOT NULL," // Med_MAX_BYTES_ATTRIBUTION - "Name_ca VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME - "Name_de VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME - "Name_en VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME - "Name_es VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME - "Name_fr VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME - "Name_gn VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME - "Name_it VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME - "Name_pl VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME - "Name_pt VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME - "WWW_ca VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW - "WWW_de VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW - "WWW_en VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW - "WWW_es VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW - "WWW_fr VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW - "WWW_gn VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW - "WWW_it VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW - "WWW_pl VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW - "WWW_pt VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW - "UNIQUE INDEX(CtyCod),UNIQUE INDEX(Alpha2)," - "INDEX(Name_ca)," - "INDEX(Name_de)," - "INDEX(Name_en)," - "INDEX(Name_es)," - "INDEX(Name_fr)," - "INDEX(Name_gn)," - "INDEX(Name_it)," - "INDEX(Name_pl)," - "INDEX(Name_pt))"); // ISO 3166-1 country codes - /***** Table crs_courses *****/ /* mysql> DESCRIBE crs_courses; @@ -910,6 +808,108 @@ mysql> DESCRIBE crs_usr_requests; "UNIQUE INDEX(CrsCod,UsrCod)," "INDEX(UsrCod))"); + /***** Table ctr_centers *****/ +/* +mysql> DESCRIBE ctr_centers; ++------------------+---------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++------------------+---------------+------+-----+---------+----------------+ +| CtrCod | int(11) | NO | PRI | NULL | auto_increment | +| InsCod | int(11) | NO | MUL | NULL | | +| PlcCod | int(11) | NO | MUL | -1 | | +| Status | tinyint(4) | NO | MUL | 0 | | +| RequesterUsrCod | int(11) | NO | | -1 | | +| Latitude | double | NO | | 0 | | +| Longitude | double | NO | | 0 | | +| Altitude | double | NO | | 0 | | +| ShortName | varchar(511) | NO | | NULL | | +| FullName | varchar(2047) | NO | | NULL | | +| WWW | varchar(255) | NO | | NULL | | +| PhotoAttribution | text | NO | | NULL | | ++------------------+---------------+------+-----+---------+----------------+ +12 rows in set (0.00 sec) +*/ + DB_CreateTable ("CREATE TABLE IF NOT EXISTS ctr_centers (" + "CtrCod INT NOT NULL AUTO_INCREMENT," + "InsCod INT NOT NULL," + "PlcCod INT NOT NULL," + "Status TINYINT NOT NULL DEFAULT 0," + "RequesterUsrCod INT NOT NULL DEFAULT -1," + "Latitude DOUBLE PRECISION NOT NULL DEFAULT 0," + "Longitude DOUBLE PRECISION NOT NULL DEFAULT 0," + "Altitude DOUBLE PRECISION NOT NULL DEFAULT 0," + "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_SHRT_NAME + "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Cns_HIERARCHY_MAX_BYTES_FULL_NAME + "WWW VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "PhotoAttribution TEXT NOT NULL," // Med_MAX_BYTES_ATTRIBUTION + "UNIQUE INDEX(CtrCod)," + "INDEX(InsCod)," + "INDEX(PlcCod)," + "INDEX(Status))"); + + /***** Table cty_countrs *****/ +/* +mysql> DESCRIBE cty_countrs; ++----------------+--------------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++----------------+--------------+------+-----+---------+-------+ +| CtyCod | int(11) | NO | PRI | NULL | | +| Alpha2 | char(2) | NO | UNI | NULL | | +| MapAttribution | text | NO | | NULL | | +| Name_ca | varchar(767) | NO | MUL | NULL | | +| Name_de | varchar(767) | NO | MUL | NULL | | +| Name_en | varchar(767) | NO | MUL | NULL | | +| Name_es | varchar(767) | NO | MUL | NULL | | +| Name_fr | varchar(767) | NO | MUL | NULL | | +| Name_gn | varchar(767) | NO | MUL | NULL | | +| Name_it | varchar(767) | NO | MUL | NULL | | +| Name_pl | varchar(767) | NO | MUL | NULL | | +| Name_pt | varchar(767) | NO | MUL | NULL | | +| WWW_ca | varchar(255) | NO | | NULL | | +| WWW_de | varchar(255) | NO | | NULL | | +| WWW_en | varchar(255) | NO | | NULL | | +| WWW_es | varchar(255) | NO | | NULL | | +| WWW_fr | varchar(255) | NO | | NULL | | +| WWW_gn | varchar(255) | NO | | NULL | | +| WWW_it | varchar(255) | NO | | NULL | | +| WWW_pl | varchar(255) | NO | | NULL | | +| WWW_pt | varchar(255) | NO | | NULL | | ++----------------+--------------+------+-----+---------+-------+ +21 rows in set (0,00 sec) +*/ + DB_CreateTable ("CREATE TABLE IF NOT EXISTS cty_countrs (" + "CtyCod INT NOT NULL," + "Alpha2 CHAR(2) NOT NULL," + "MapAttribution TEXT NOT NULL," // Med_MAX_BYTES_ATTRIBUTION + "Name_ca VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME + "Name_de VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME + "Name_en VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME + "Name_es VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME + "Name_fr VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME + "Name_gn VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME + "Name_it VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME + "Name_pl VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME + "Name_pt VARCHAR(767) NOT NULL," // Cty_MAX_BYTES_NAME + "WWW_ca VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "WWW_de VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "WWW_en VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "WWW_es VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "WWW_fr VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "WWW_gn VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "WWW_it VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "WWW_pl VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "WWW_pt VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "UNIQUE INDEX(CtyCod),UNIQUE INDEX(Alpha2)," + "INDEX(Name_ca)," + "INDEX(Name_de)," + "INDEX(Name_en)," + "INDEX(Name_es)," + "INDEX(Name_fr)," + "INDEX(Name_gn)," + "INDEX(Name_it)," + "INDEX(Name_pl)," + "INDEX(Name_pt))"); // ISO 3166-1 country codes + /***** Table deg_types *****/ /* mysql> DESCRIBE deg_types; diff --git a/swad_institution.c b/swad_institution.c index ee175b83..72deb347 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -959,12 +959,12 @@ static void Ins_GetShrtNameAndCtyOfInstitution (struct Ins_Instit *Ins, if (DB_QuerySELECT (&mysql_res,"can not get short name and country" " of an institution", - "SELECT ins_instits.ShortName," - "countries.Name_%s" + "SELECT ins_instits.ShortName," // row[0] + "cty_countrs.Name_%s" // row[1] " FROM ins_instits," - "countries" + "cty_countrs" " WHERE ins_instits.InsCod=%ld" - " AND ins_instits.CtyCod=countries.CtyCod", + " AND ins_instits.CtyCod=cty_countrs.CtyCod", Lan_STR_LANG_ID[Gbl.Prefs.Language],Ins->InsCod) == 1) { /* Get row */ diff --git a/swad_search.c b/swad_search.c index 83161a63..66961e83 100644 --- a/swad_search.c +++ b/swad_search.c @@ -354,7 +354,7 @@ static void Sch_SearchInDB (void) RangeQuery[0] = '\0'; break; case Hie_Lvl_CTY: - sprintf (RangeQuery," AND countries.CtyCod=%ld", + sprintf (RangeQuery," AND cty_countrs.CtyCod=%ld", Gbl.Hierarchy.Cty.CtyCod); break; case Hie_Lvl_INS: @@ -464,13 +464,14 @@ static unsigned Sch_SearchCountriesInDB (const char *RangeQuery) if (Sch_BuildSearchQuery (SearchQuery,FieldName,NULL,NULL)) { /***** Query database and list institutions found *****/ - NumCtys = (unsigned) DB_QuerySELECT (&mysql_res,"can not get countries", - "SELECT CtyCod" - " FROM countries" - " WHERE %s%s" - " ORDER BY Name_%s", - SearchQuery,RangeQuery, - Lan_STR_LANG_ID[Gbl.Prefs.Language]); + NumCtys = (unsigned) + DB_QuerySELECT (&mysql_res,"can not get countries", + "SELECT CtyCod" // row[0] + " FROM cty_countrs" + " WHERE %s%s" + " ORDER BY Name_%s", + SearchQuery,RangeQuery, + Lan_STR_LANG_ID[Gbl.Prefs.Language]); Cty_ListCtysFound (&mysql_res,NumCtys); return NumCtys; } @@ -503,13 +504,14 @@ static unsigned Sch_SearchInstitutionsInDB (const char *RangeQuery) /***** Query database and list institutions found *****/ NumInss = (unsigned) DB_QuerySELECT (&mysql_res,"can not get institutions", - "SELECT ins_instits.InsCod" + "SELECT ins_instits.InsCod" // row[0] " FROM ins_instits," - "countries" + "cty_countrs" " WHERE %s" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" - " ORDER BY ins_instits.FullName,countries.Name_%s", + " ORDER BY ins_instits.FullName," + "cty_countrs.Name_%s", SearchQuery,RangeQuery, Lan_STR_LANG_ID[Gbl.Prefs.Language]); Ins_ListInssFound (&mysql_res,NumInss); @@ -541,13 +543,13 @@ static unsigned Sch_SearchCentersInDB (const char *RangeQuery) /***** Query database and list centers found *****/ NumCtrs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get centers", - "SELECT ctr_centers.CtrCod" + "SELECT ctr_centers.CtrCod" // row[0] " FROM ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE %s" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " ORDER BY ctr_centers.FullName," "ins_instits.FullName", @@ -580,14 +582,15 @@ static unsigned Sch_SearchDegreesInDB (const char *RangeQuery) /***** Query database and list degrees found *****/ NumDegs = (unsigned) DB_QuerySELECT (&mysql_res,"can not get degrees", - "SELECT deg_degrees.DegCod" + "SELECT deg_degrees.DegCod" // row[0] " FROM deg_degrees," "ctr_centers," - "ins_instits,countries" + "ins_instits," + "cty_countrs" " WHERE %s" " AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " ORDER BY deg_degrees.FullName," "ins_instits.FullName", @@ -629,12 +632,12 @@ static unsigned Sch_SearchCoursesInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE %s" " AND crs_courses.DegCod=deg_degrees.DegCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " ORDER BY crs_courses.FullName," "ins_instits.FullName," @@ -716,11 +719,11 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.Public='Y' AND %s" " AND files.FileBrowser IN (%u,%u)" " AND files.Cod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " UNION " "SELECT files.FilCod," // Center @@ -739,12 +742,12 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.Public='Y' AND %s" " AND files.FileBrowser IN (%u,%u)" " AND files.Cod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " UNION " "SELECT files.FilCod," // Degree @@ -762,13 +765,13 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.Public='Y' AND %s" " AND files.FileBrowser IN (%u,%u)" " AND files.Cod=deg_degrees.DegCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " UNION " "SELECT files.FilCod," // Course @@ -787,14 +790,14 @@ static unsigned Sch_SearchOpenDocumentsInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.Public='Y' AND %s" " AND files.FileBrowser IN (%u,%u)" " AND files.Cod=crs_courses.CrsCod" " AND crs_courses.DegCod=deg_degrees.DegCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" ") AS selected_files" " WHERE PathFromRoot<>''" @@ -903,14 +906,14 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.FilCod IN (SELECT FilCod FROM my_files_crs) AND %s" " AND files.FileBrowser IN (%u,%u,%u,%u)" " AND files.Cod=crs_courses.CrsCod" " AND crs_courses.DegCod=deg_degrees.DegCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " UNION " "SELECT files.FilCod," @@ -931,7 +934,7 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.FilCod IN (SELECT FilCod FROM my_files_grp) AND %s" " AND files.FileBrowser IN (%u,%u,%u,%u)" " AND files.Cod=crs_grp.GrpCod" @@ -940,7 +943,7 @@ static unsigned Sch_SearchDocumentsInMyCoursesInDB (const char *RangeQuery) " AND crs_courses.DegCod=deg_degrees.DegCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" ") AS selected_files" " WHERE PathFromRoot<>''" @@ -1016,11 +1019,11 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.PublisherUsrCod=%ld AND %s" " AND files.FileBrowser IN (%u,%u)" " AND files.Cod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " UNION " "SELECT files.FilCod," // Center @@ -1039,12 +1042,12 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.PublisherUsrCod=%ld AND %s" " AND files.FileBrowser IN (%u,%u)" " AND files.Cod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " UNION " "SELECT files.FilCod," // Degree @@ -1063,13 +1066,13 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.PublisherUsrCod=%ld AND %s" " AND files.FileBrowser IN (%u,%u)" " AND files.Cod=deg_degrees.DegCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " UNION " "SELECT files.FilCod," // Course @@ -1088,14 +1091,14 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.PublisherUsrCod=%ld AND %s" " AND files.FileBrowser IN (%u,%u,%u,%u)" " AND files.Cod=crs_courses.CrsCod" " AND crs_courses.DegCod=deg_degrees.DegCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " UNION " "SELECT files.FilCod," // Group @@ -1116,7 +1119,7 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery) "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE files.PublisherUsrCod=%ld AND %s" " AND files.FileBrowser IN (%u,%u,%u,%u)" " AND files.Cod=crs_grp.GrpCod" @@ -1125,7 +1128,7 @@ static unsigned Sch_SearchMyDocumentsInDB (const char *RangeQuery) " AND crs_courses.DegCod=deg_degrees.DegCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" + " AND ins_instits.CtyCod=cty_countrs.CtyCod" "%s" " UNION " "SELECT files.FilCod," // Briefcase diff --git a/swad_user.c b/swad_user.c index be24bf3c..6b0012b3 100644 --- a/swad_user.c +++ b/swad_user.c @@ -2201,22 +2201,22 @@ unsigned Usr_GetCtysFromUsr (long UsrCod,MYSQL_RES **mysql_res) return (unsigned) DB_QuerySELECT (mysql_res,"can not get the countries" " a user belongs to", - "SELECT countries.CtyCod," - "MAX(crs_usr.Role)" + "SELECT cty_countrs.CtyCod," // row[0] + "MAX(crs_usr.Role)" // row[1] " FROM crs_usr," "crs_courses," "deg_degrees," "ctr_centers," "ins_instits," - "countries" + "cty_countrs" " WHERE crs_usr.UsrCod=%ld" " AND crs_usr.CrsCod=crs_courses.CrsCod" " AND crs_courses.DegCod=deg_degrees.DegCod" " AND deg_degrees.CtrCod=ctr_centers.CtrCod" " AND ctr_centers.InsCod=ins_instits.InsCod" - " AND ins_instits.CtyCod=countries.CtyCod" - " GROUP BY countries.CtyCod" - " ORDER BY countries.Name_%s", + " AND ins_instits.CtyCod=cty_countrs.CtyCod" + " GROUP BY cty_countrs.CtyCod" + " ORDER BY cty_countrs.Name_%s", UsrCod,Lan_STR_LANG_ID[Gbl.Prefs.Language]); }