Ignore:
Timestamp:
07/05/08 20:01:55 (16 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/msql
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/msql/MSQLMagic.cc

    r8987 r8996  
    187187}
    188188
    189 Bool_t MSQLMagic::ExistStr(const char *column, const char *table, const char *test)
    190 {
    191     TString query(Form("SELECT %s FROM %s WHERE %s='%s'", column, table, column, test));
     189// --------------------------------------------------------------------------
     190//
     191// Check if the column of an entry in a table is existing and not null.
     192// The entry is defined by column=test (column name) and a optional
     193// WHERE statement.
     194//
     195Bool_t MSQLMagic::ExistStr(const char *column, const char *table, const char *test, const char *where)
     196{
     197    TString query(Form("SELECT %s FROM %s WHERE %s='%s' %s %s", column, table, column, test, where?"AND":"", where?where:""));
    192198    TSQLResult *res = Query(query);
    193199    if (!res)
  • trunk/MagicSoft/Mars/msql/MSQLMagic.h

    r8942 r8996  
    4444    Int_t   QueryKeyOfVal(const char *col, const char *val);
    4545    Int_t   QueryKeyOf(const char *col, const char *ext, const char *val);
    46     Bool_t  ExistStr(const char *column, const char *table, const char *test);
     46    Bool_t  ExistStr(const char *column, const char *table, const char *test, const char *where=0);
    4747
    4848    Int_t Insert(const char *table, const char *vars, const char *where=0);
  • trunk/MagicSoft/Mars/msql/MSQLServer.cc

    r8907 r8996  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MSQLServer.cc,v 1.15 2008-06-02 08:46:49 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MSQLServer.cc,v 1.16 2008-07-05 18:57:35 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    668668}
    669669
     670// --------------------------------------------------------------------------
     671//
     672// Instantiate a dabase connection either by
     673//   mysql://user:password@url/database
     674// or by a resource file (in teh given string doesn't contain mysql://)
     675//
    670676MSQLServer::MSQLServer(const char *u) : fType(kIsZombie) /*FOLD00*/
    671677{
    672     TString url(u);
    673     TString user, pasw;
    674 
    675     if (!Split(url, user, pasw))
    676     {
    677         fType = kIsZombie;
    678         return;
    679     }
    680     Init(url, user, pasw);
     678    if (TString(u).Contains("mysql://", TString::kIgnoreCase))
     679    {
     680        TString url(u);
     681        TString user, pasw;
     682
     683        if (!Split(url, user, pasw))
     684        {
     685            fType = kIsZombie;
     686            return;
     687        }
     688        Init(url, user, pasw);
     689    }
     690    else
     691    {
     692        TEnv env(u);
     693        InitEnv(env);
     694    }
    681695}
    682696
     
    781795        if (key=="PRI")
    782796        {
    783             rc = (*row)[0];
    784             break;
     797            if (!rc.IsNull())
     798                rc += ", ";
     799            rc += (*row)[0];
    785800        }
    786801        delete row;
     
    823838
    824839        const TString tab = expr(0, expr.First('.'));
    825         const TString var = expr(expr.First('.')+1, expr.Length());
     840        //const TString var = expr(expr.First('.')+1, expr.Length());
    826841
    827842        // If the table found is the primary table itself skip it.
     
    838853            continue;
    839854
    840         joins += Form("LEFT JOIN %s ON %s.%s=%s.%s ", tab.Data(),
    841                       table, prim.Data(), tab.Data(), prim.Data());
     855        joins += Form("LEFT JOIN %s USING (%s) ", tab.Data(), prim.Data());
    842856    }
    843857
Note: See TracChangeset for help on using the changeset viewer.