Minor source cleaning.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38385 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: dbtable.cpp
|
// Name: src/common/dbtable.cpp
|
||||||
// Purpose: Implementation of the wxDbTable class.
|
// Purpose: Implementation of the wxDbTable class.
|
||||||
// Author: Doug Card
|
// Author: Doug Card
|
||||||
// Modified by: George Tasker
|
// Modified by: George Tasker
|
||||||
@@ -22,6 +22,8 @@
|
|||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_ODBC
|
||||||
|
|
||||||
#ifdef DBDEBUG_CONSOLE
|
#ifdef DBDEBUG_CONSOLE
|
||||||
#if wxUSE_IOSTREAMH
|
#if wxUSE_IOSTREAMH
|
||||||
#include <iostream.h>
|
#include <iostream.h>
|
||||||
@@ -40,8 +42,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#include "wx/filefn.h"
|
#include "wx/filefn.h"
|
||||||
|
|
||||||
#if wxUSE_ODBC
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -159,7 +159,7 @@ bool wxDbTable::initialize(wxDb *pwxDb, const wxString &tblName, const UWORD num
|
|||||||
tableName.Empty();
|
tableName.Empty();
|
||||||
queryTableName.Empty();
|
queryTableName.Empty();
|
||||||
|
|
||||||
wxASSERT(tblName.Length());
|
wxASSERT(tblName.length());
|
||||||
wxASSERT(pDb);
|
wxASSERT(pDb);
|
||||||
|
|
||||||
if (!pDb)
|
if (!pDb)
|
||||||
@@ -171,12 +171,12 @@ bool wxDbTable::initialize(wxDb *pwxDb, const wxString &tblName, const UWORD num
|
|||||||
(pDb->Dbms() == dbmsINTERBASE))
|
(pDb->Dbms() == dbmsINTERBASE))
|
||||||
tableName = tableName.Upper();
|
tableName = tableName.Upper();
|
||||||
|
|
||||||
if (tblPath.Length())
|
if (tblPath.length())
|
||||||
tablePath = tblPath; // Table Path - used for dBase files
|
tablePath = tblPath; // Table Path - used for dBase files
|
||||||
else
|
else
|
||||||
tablePath.Empty();
|
tablePath.Empty();
|
||||||
|
|
||||||
if (qryTblName.Length()) // Name of the table/view to query
|
if (qryTblName.length()) // Name of the table/view to query
|
||||||
queryTableName = qryTblName;
|
queryTableName = qryTblName;
|
||||||
else
|
else
|
||||||
queryTableName = tblName;
|
queryTableName = tblName;
|
||||||
@@ -419,7 +419,6 @@ void wxDbTable::setCbValueForColumn(int columnIndex)
|
|||||||
else
|
else
|
||||||
colDefs[columnIndex].CbValue = SQL_NTS;
|
colDefs[columnIndex].CbValue = SQL_NTS;
|
||||||
break;
|
break;
|
||||||
break;
|
|
||||||
case DB_DATA_TYPE_INTEGER:
|
case DB_DATA_TYPE_INTEGER:
|
||||||
if (colDefs[columnIndex].Null)
|
if (colDefs[columnIndex].Null)
|
||||||
colDefs[columnIndex].CbValue = SQL_NULL_DATA;
|
colDefs[columnIndex].CbValue = SQL_NULL_DATA;
|
||||||
@@ -994,7 +993,7 @@ void wxDbTable::BuildDeleteStmt(wxString &pSqlStmt, int typeOfDel, const wxStrin
|
|||||||
|
|
||||||
// Handle the case of DeleteWhere() and the where clause is blank. It should
|
// Handle the case of DeleteWhere() and the where clause is blank. It should
|
||||||
// delete all records from the database in this case.
|
// 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"),
|
pSqlStmt.Printf(wxT("DELETE FROM %s"),
|
||||||
pDb->SQLTableName(tableName.c_str()).c_str());
|
pDb->SQLTableName(tableName.c_str()).c_str());
|
||||||
@@ -1073,7 +1072,7 @@ void wxDbTable::BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool disti
|
|||||||
if (typeOfSelect == DB_SELECT_WHERE && from && wxStrlen(from))
|
if (typeOfSelect == DB_SELECT_WHERE && from && wxStrlen(from))
|
||||||
appendFromClause = true;
|
appendFromClause = true;
|
||||||
#else
|
#else
|
||||||
if (typeOfSelect == DB_SELECT_WHERE && from.Length())
|
if (typeOfSelect == DB_SELECT_WHERE && from.length())
|
||||||
appendFromClause = true;
|
appendFromClause = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1133,7 +1132,7 @@ void wxDbTable::BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool disti
|
|||||||
#if wxODBC_BACKWARD_COMPATABILITY
|
#if wxODBC_BACKWARD_COMPATABILITY
|
||||||
if (where && wxStrlen(where)) // May not want a where clause!!!
|
if (where && wxStrlen(where)) // May not want a where clause!!!
|
||||||
#else
|
#else
|
||||||
if (where.Length()) // May not want a where clause!!!
|
if (where.length()) // May not want a where clause!!!
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
pSqlStmt += wxT(" WHERE ");
|
pSqlStmt += wxT(" WHERE ");
|
||||||
@@ -1142,7 +1141,7 @@ void wxDbTable::BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool disti
|
|||||||
break;
|
break;
|
||||||
case DB_SELECT_KEYFIELDS:
|
case DB_SELECT_KEYFIELDS:
|
||||||
BuildWhereClause(whereClause, DB_WHERE_KEYFIELDS);
|
BuildWhereClause(whereClause, DB_WHERE_KEYFIELDS);
|
||||||
if (whereClause.Length())
|
if (whereClause.length())
|
||||||
{
|
{
|
||||||
pSqlStmt += wxT(" WHERE ");
|
pSqlStmt += wxT(" WHERE ");
|
||||||
pSqlStmt += whereClause;
|
pSqlStmt += whereClause;
|
||||||
@@ -1150,7 +1149,7 @@ void wxDbTable::BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool disti
|
|||||||
break;
|
break;
|
||||||
case DB_SELECT_MATCHING:
|
case DB_SELECT_MATCHING:
|
||||||
BuildWhereClause(whereClause, DB_WHERE_MATCHING);
|
BuildWhereClause(whereClause, DB_WHERE_MATCHING);
|
||||||
if (whereClause.Length())
|
if (whereClause.length())
|
||||||
{
|
{
|
||||||
pSqlStmt += wxT(" WHERE ");
|
pSqlStmt += wxT(" WHERE ");
|
||||||
pSqlStmt += whereClause;
|
pSqlStmt += whereClause;
|
||||||
@@ -1162,7 +1161,7 @@ void wxDbTable::BuildSelectStmt(wxString &pSqlStmt, int typeOfSelect, bool disti
|
|||||||
#if wxODBC_BACKWARD_COMPATABILITY
|
#if wxODBC_BACKWARD_COMPATABILITY
|
||||||
if (orderBy && wxStrlen(orderBy))
|
if (orderBy && wxStrlen(orderBy))
|
||||||
#else
|
#else
|
||||||
if (orderBy.Length())
|
if (orderBy.length())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
pSqlStmt += wxT(" ORDER BY ");
|
pSqlStmt += wxT(" ORDER BY ");
|
||||||
@@ -1296,7 +1295,7 @@ void wxDbTable::BuildWhereClause(wxString &pWhereClause, int typeOfWhere,
|
|||||||
// Concatenate where phrase for the column
|
// Concatenate where phrase for the column
|
||||||
wxString tStr = colDefs[colNumber].ColName;
|
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 += pDb->SQLTableName(qualTableName);
|
||||||
pWhereClause += wxT(".");
|
pWhereClause += wxT(".");
|
||||||
@@ -2302,7 +2301,7 @@ bool wxDbTable::SetColDefs(UWORD index, const wxString &fieldName, int dataType,
|
|||||||
if (!colDefs) // May happen if the database connection fails
|
if (!colDefs) // May happen if the database connection fails
|
||||||
return false;
|
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);
|
wxStrncpy(colDefs[index].ColName, fieldName, DB_MAX_COLUMN_NAME_LEN);
|
||||||
colDefs[index].ColName[DB_MAX_COLUMN_NAME_LEN] = 0; // Prevent buffer overrun
|
colDefs[index].ColName[DB_MAX_COLUMN_NAME_LEN] = 0; // Prevent buffer overrun
|
||||||
@@ -2456,7 +2455,7 @@ ULONG wxDbTable::Count(const wxString &args)
|
|||||||
#if wxODBC_BACKWARD_COMPATABILITY
|
#if wxODBC_BACKWARD_COMPATABILITY
|
||||||
if (from && wxStrlen(from))
|
if (from && wxStrlen(from))
|
||||||
#else
|
#else
|
||||||
if (from.Length())
|
if (from.length())
|
||||||
#endif
|
#endif
|
||||||
sqlStmt += from;
|
sqlStmt += from;
|
||||||
|
|
||||||
@@ -2464,7 +2463,7 @@ ULONG wxDbTable::Count(const wxString &args)
|
|||||||
#if wxODBC_BACKWARD_COMPATABILITY
|
#if wxODBC_BACKWARD_COMPATABILITY
|
||||||
if (where && wxStrlen(where))
|
if (where && wxStrlen(where))
|
||||||
#else
|
#else
|
||||||
if (where.Length())
|
if (where.length())
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
sqlStmt += wxT(" WHERE ");
|
sqlStmt += wxT(" WHERE ");
|
||||||
@@ -2922,4 +2921,3 @@ void wxDbTable::SetKey(const GenericKey& k)
|
|||||||
|
|
||||||
|
|
||||||
#endif // wxUSE_ODBC
|
#endif // wxUSE_ODBC
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user