Ignore:
Timestamp:
12/21/08 18:09:49 (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

    r9039 r9195  
    3333#include "MSQLMagic.h"
    3434
     35#include <stdlib.h> // atoi (Ubuntu 8.10)
     36
    3537#include <iostream>
    3638
  • trunk/MagicSoft/Mars/msql/MSQLServer.cc

    r8996 r9195  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MSQLServer.cc,v 1.16 2008-07-05 18:57:35 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MSQLServer.cc,v 1.17 2008-12-21 18:09:49 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    5858#include <TBrowser.h>
    5959
     60#include <TObjString.h>
     61#include <TObjArray.h>
     62
    6063ClassImp(MSQLServer);
    6164
     
    781784// Return the name of the (first) column with a primary key
    782785//
    783 TString MSQLServer::GetPrimaryKey(const char *table)
     786TString MSQLServer::GetPrimaryKeys(const char *table)
    784787{
    785788    TSQLResult *res = GetColumns(table);
     
    787790        return "";
    788791
    789     TString rc;
     792    TObjArray arr;
     793    arr.SetOwner();
    790794
    791795    TSQLRow *row = 0;
     
    794798        const TString key = (*row)[3];
    795799        if (key=="PRI")
    796         {
    797             if (!rc.IsNull())
    798                 rc += ", ";
    799             rc += (*row)[0];
    800         }
     800            arr.Add(new TObjString((*row)[0]));
    801801        delete row;
    802802    }
    803 
    804803    delete res;
     804
     805    arr.Sort();
     806
     807    TString rc;
     808    for (int i=0; i<arr.GetEntries(); i++)
     809    {
     810        if (i>0)
     811            rc += ", ";
     812        rc += arr[i]->GetName();
     813    }
    805814    return rc;
    806815}
     
    849858
    850859        // Now get the primary key of the table to be joined
    851         const TString prim = GetPrimaryKey(tab);
     860        const TString prim = GetPrimaryKeys(tab);
    852861        if (prim.IsNull())
    853862            continue;
  • trunk/MagicSoft/Mars/msql/MSQLServer.h

    r8185 r9195  
    123123
    124124    TString     GetEntry(const char *where, const char *col=0, const char *table=0) const;
    125     TString     GetPrimaryKey(const char *table);
     125    TString     GetPrimaryKeys(const char *table);
    126126    TString     GetJoins(const char *table, const TString text);
    127127
Note: See TracChangeset for help on using the changeset viewer.