X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e716b9bee14786f7a73da502fbd601c57ce03ebc..77a1771911ed222ba6861ead327c3735fc16a0b1:/src/common/dbtable.cpp?ds=sidebyside diff --git a/src/common/dbtable.cpp b/src/common/dbtable.cpp index 7e5b6f1bd0..346dcd34f9 100644 --- a/src/common/dbtable.cpp +++ b/src/common/dbtable.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: dbtable.cpp +// Name: src/common/dbtable.cpp // Purpose: Implementation of the wxDbTable class. // Author: Doug Card // Modified by: George Tasker @@ -11,21 +11,22 @@ // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// -/* -// SYNOPSIS START -// SYNOPSIS STOP -*/ - -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "dbtable.h" -#endif - #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif +#if wxUSE_ODBC + +#ifndef WX_PRECOMP + #include "wx/object.h" + #include "wx/list.h" + #include "wx/string.h" + #include "wx/utils.h" + #include "wx/log.h" +#endif + #ifdef DBDEBUG_CONSOLE #if wxUSE_IOSTREAMH #include @@ -35,17 +36,8 @@ #include "wx/ioswrap.h" #endif -#ifndef WX_PRECOMP - #include "wx/string.h" - #include "wx/object.h" - #include "wx/list.h" - #include "wx/utils.h" - #include "wx/log.h" -#endif #include "wx/filefn.h" -#if wxUSE_ODBC - #include #include #include @@ -163,7 +155,7 @@ bool wxDbTable::initialize(wxDb *pwxDb, const wxString &tblName, const UWORD num tableName.Empty(); queryTableName.Empty(); - wxASSERT(tblName.Length()); + wxASSERT(tblName.length()); wxASSERT(pDb); if (!pDb) @@ -175,12 +167,12 @@ bool wxDbTable::initialize(wxDb *pwxDb, const wxString &tblName, const UWORD num (pDb->Dbms() == dbmsINTERBASE)) tableName = tableName.Upper(); - if (tblPath.Length()) + if (tblPath.length()) tablePath = tblPath; // Table Path - used for dBase files else tablePath.Empty(); - if (qryTblName.Length()) // Name of the table/view to query + if (qryTblName.length()) // Name of the table/view to query queryTableName = qryTblName; else queryTableName = tblName; @@ -417,6 +409,7 @@ void wxDbTable::setCbValueForColumn(int columnIndex) switch(colDefs[columnIndex].DbDataType) { case DB_DATA_TYPE_VARCHAR: + case DB_DATA_TYPE_MEMO: if (colDefs[columnIndex].Null) colDefs[columnIndex].CbValue = SQL_NULL_DATA; else @@ -488,6 +481,11 @@ bool wxDbTable::bindParams(bool forUpdate) precision = colDefs[i].SzDataObj; scale = 0; break; + case DB_DATA_TYPE_MEMO: + fSqlType = pDb->GetTypeInfMemo().FsqlType; + precision = colDefs[i].SzDataObj; + scale = 0; + break; case DB_DATA_TYPE_INTEGER: fSqlType = pDb->GetTypeInfInteger().FsqlType; precision = pDb->GetTypeInfInteger().Precision; @@ -991,7 +989,7 @@ void wxDbTable::BuildDeleteStmt(wxString &pSqlStmt, int typeOfDel, const wxStrin // Handle the case of DeleteWhere() and the where clause is blank. It should // delete all records from the database in this case. - if (typeOfDel == DB_DEL_WHERE && (pWhereClause.Length() == 0)) + if (typeOfDel == DB_DEL_WHERE && (pWhereClause.length() == 0)) { pSqlStmt.Printf(wxT("DELETE FROM %s"), pDb->SQLTableName(tableName.c_str()).c_str()); @@ -1070,7 +1068,7 @@ void wxDbTable::BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool disti if (typeOfSelect == DB_SELECT_WHERE && from && wxStrlen(from)) appendFromClause = true; #else - if (typeOfSelect == DB_SELECT_WHERE && from.Length()) + if (typeOfSelect == DB_SELECT_WHERE && from.length()) appendFromClause = true; #endif @@ -1130,7 +1128,7 @@ void wxDbTable::BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool disti #if wxODBC_BACKWARD_COMPATABILITY if (where && wxStrlen(where)) // May not want a where clause!!! #else - if (where.Length()) // May not want a where clause!!! + if (where.length()) // May not want a where clause!!! #endif { pSqlStmt += wxT(" WHERE "); @@ -1139,7 +1137,7 @@ void wxDbTable::BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool disti break; case DB_SELECT_KEYFIELDS: BuildWhereClause(whereClause, DB_WHERE_KEYFIELDS); - if (whereClause.Length()) + if (whereClause.length()) { pSqlStmt += wxT(" WHERE "); pSqlStmt += whereClause; @@ -1147,7 +1145,7 @@ void wxDbTable::BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool disti break; case DB_SELECT_MATCHING: BuildWhereClause(whereClause, DB_WHERE_MATCHING); - if (whereClause.Length()) + if (whereClause.length()) { pSqlStmt += wxT(" WHERE "); pSqlStmt += whereClause; @@ -1159,7 +1157,7 @@ void wxDbTable::BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool disti #if wxODBC_BACKWARD_COMPATABILITY if (orderBy && wxStrlen(orderBy)) #else - if (orderBy.Length()) + if (orderBy.length()) #endif { pSqlStmt += wxT(" ORDER BY "); @@ -1293,7 +1291,7 @@ void wxDbTable::BuildWhereClause(wxString &pWhereClause, int typeOfWhere, // Concatenate where phrase for the column wxString tStr = colDefs[colNumber].ColName; - if (qualTableName.Length() && tStr.Find(wxT('.')) == wxNOT_FOUND) + if (qualTableName.length() && tStr.Find(wxT('.')) == wxNOT_FOUND) { pWhereClause += pDb->SQLTableName(qualTableName); pWhereClause += wxT("."); @@ -1418,6 +1416,9 @@ bool wxDbTable::CreateTable(bool attemptDrop) case DB_DATA_TYPE_VARCHAR: cout << pDb->GetTypeInfVarchar().TypeName << wxT("(") << (int)(colDefs[i].SzDataObj / sizeof(wxChar)) << wxT(")"); break; + case DB_DATA_TYPE_MEMO: + cout << pDb->GetTypeInfMemo().TypeName; + break; case DB_DATA_TYPE_INTEGER: cout << pDb->GetTypeInfInteger().TypeName; break; @@ -1459,6 +1460,9 @@ bool wxDbTable::CreateTable(bool attemptDrop) case DB_DATA_TYPE_VARCHAR: sqlStmt += pDb->GetTypeInfVarchar().TypeName; break; + case DB_DATA_TYPE_MEMO: + sqlStmt += pDb->GetTypeInfMemo().TypeName; + break; case DB_DATA_TYPE_INTEGER: sqlStmt += pDb->GetTypeInfInteger().TypeName; break; @@ -2293,7 +2297,7 @@ bool wxDbTable::SetColDefs(UWORD index, const wxString &fieldName, int dataType, if (!colDefs) // May happen if the database connection fails return false; - if (fieldName.Length() > (unsigned int) DB_MAX_COLUMN_NAME_LEN) + if (fieldName.length() > (unsigned int) DB_MAX_COLUMN_NAME_LEN) { wxStrncpy(colDefs[index].ColName, fieldName, DB_MAX_COLUMN_NAME_LEN); colDefs[index].ColName[DB_MAX_COLUMN_NAME_LEN] = 0; // Prevent buffer overrun @@ -2353,6 +2357,11 @@ wxDbColDataPtr* wxDbTable::SetColDefs(wxDbColInf *pColInfs, UWORD numCols) pColDataPtrs[index].SzDataObj = pColInfs[index].bufferSize+(1*sizeof(wxChar)); pColDataPtrs[index].SqlCtype = SQL_C_WXCHAR; break; + case DB_DATA_TYPE_MEMO: + pColDataPtrs[index].PtrDataObj = new wxChar[pColInfs[index].bufferSize+(1*sizeof(wxChar))]; + pColDataPtrs[index].SzDataObj = pColInfs[index].bufferSize+(1*sizeof(wxChar)); + pColDataPtrs[index].SqlCtype = SQL_C_WXCHAR; + break; case DB_DATA_TYPE_INTEGER: // Can be long or short if (pColInfs[index].bufferSize == sizeof(long)) @@ -2442,7 +2451,7 @@ ULONG wxDbTable::Count(const wxString &args) #if wxODBC_BACKWARD_COMPATABILITY if (from && wxStrlen(from)) #else - if (from.Length()) + if (from.length()) #endif sqlStmt += from; @@ -2450,7 +2459,7 @@ ULONG wxDbTable::Count(const wxString &args) #if wxODBC_BACKWARD_COMPATABILITY if (where && wxStrlen(where)) #else - if (where.Length()) + if (where.length()) #endif { sqlStmt += wxT(" WHERE "); @@ -2908,4 +2917,3 @@ void wxDbTable::SetKey(const GenericKey& k) #endif // wxUSE_ODBC -