Abstract class that represents a query used or created by a ColdFusion Extension (CFX). Queries contain 1 or more columns of data that extend over a varying number of rows.
virtual int AddRow()
CCFXQuery::AddRow adds a new row to the query.
virtual CCFXStringSet* GetColumnsCCFXQuery::GetColumns retrieves a list of the query's column names.
virtual LPCSTR GetData( int iRow, int iColumn )CCFXQuery::GetData retrieves a data element from a row and column of the query.
virtual LPCSTR GetName()CCFXQuery::GetName retrieves the name of the query.
virtual int GetRowCount()CCFXQuery::GetRowCount retrieves the number of rows in the query.
virtual void SetData( int iRow, int iColumn, LPCSTR lpszData )CCFXQuery::SetData sets a data element within a row and column of the query.
virtual void SetQueryString( LPCSTR lpszQuery )CCFXQuery::SetQueryString sets the query string that will displayed along with query debug output.
virtual void SetTotalTime( DWORD dwMilliseconds )CCFXQuery::SetTotalTime sets the total time that was required to process the query (used for debug output).
int CCFXQuery::AddRow(void)
Add a new row to the query. You should call this function each time you want to append a row to the query.
Returns the index of the row that was appended to the query.
The following example demonstrates the addition of 2 rows to a query that has 3 columns ('City', 'State', and 'Zip'):
// First row int iRow ; iRow = pQuery->AddRow() ; pQuery->SetData( iRow, iCity, "Minneapolis" ) ; pQuery->SetData( iRow, iState, "MN" ) ; pQuery->SetData( iRow, iZip, "55345" ) ; // Second row iRow = pQuery->AddRow() ; pQuery->SetData( iRow, iCity, "St. Paul" ) ; pQuery->SetData( iRow, iState, "MN" ) ; pQuery->SetData( iRow, iZip, "55105" ) ;
CCFXStringSet* CCFXQuery::GetColumns(void)
Retrieves a list of the column names contained in the query.
Returns an object of CCFXStringSet Class that contains a list of the columns contained in the query. You are not responsible for freeing the memory allocated for the returned string set (it will be freed automatically by ColdFusion after the request is completed).
The following example retrieves the list of columns and then iterates over the list, writing each column name back to the user.
// Get the list of columns from the query CCFXStringSet* pColumns = pQuery->GetColumns() ; int nNumColumns = pColumns->GetCount() ; // Print the list of columns to the user pRequest->Write( "Columns in query: " ) ; for( int i=1; i<=nNumColumns; i++ ) { pRequest->Write( pColumns->GetString( i ) ) ; pRequest->Write( " " ) ; }
LPCSTR CCFXQuery::GetData(int iRow, int iColumn)
Retrieves a data element from a row and column of the query. Row and column indexes begin with 1. You can determine the number of rows in the query by calling CCFXQuery::GetRowCount. You can determine the number of columns in the query by retrieving the list of columns using CCFXQuery::GetColumns and then calling CCFXStringSet::GetCount on the returned string set.
Returns the value of the requested data element.
iRow
Row to retrieve data from (1-based).
lColumnColumn to retrieve data from (1-based).
The following example iterates over the elements of a query and writes the data in the query back to the user in a simple, space-delimited format:
int iRow, iCol ; int nNumCols = pQuery->GetColumns()->GetCount() ; int nNumRows = pQuery->GetRowCount() ; for ( iRow=1; iRow<=nNumRows; iRow++ ) { for ( iCol=1; iCol<=nNumCols; iCol++ ) { pRequest->Write( pQuery->GetData( iRow, iCol ) ) ; pRequest->Write( " " ) ; } pRequest->Write( "<BR>" ) ; }
LPCSTR CCFXQuery::GetName(void)
Retrieves the name of the query. Returns the name of the query.
The following example retrieves the name of the query and writes it back to the user:
CCFXQuery* pQuery = pRequest->GetQuery() ; pRequest->Write( "The query name is: " ) ; pRequest->Write( pQuery->GetName() ) ;
LPCSTR CCFXQuery::GetRowCount(void)
Retrieves the number of rows in the query. Returns the number of rows contained in the query.
The following example retrieves the number of rows in a query and writes it back to the user:
CCFXQuery* pQuery = pRequest->GetQuery() ; char buffOutput[256] ; wsprintf( buffOutput, "The number of rows in the query is %ld.", pQuery->GetRowCount() ) ; pRequest->Write( buffOutput ) ;
void CCFXQuery::SetData(int iRow, int iColumn, LPCSTR lpszData)
Sets a data element within a row and column of the query. Row and column indexes begin with 1. Before calling SetData
for a given row, you should be sure to call CCFXQuery::AddRow and use the return value as the row index for your call to SetData
.
iRow
Row of data element to set (1-based).
lColumnColumn of data element to set (1-based).
lpszDataNew value for data element.
The following example demonstrates the addition of 2 rows to a query that has 3 columns ('City', 'State', and 'Zip'):
// First row int iRow ; iRow = pQuery->AddRow() ; pQuery->SetData( iCity, iRow, "Minneapolis" ) ; pQuery->SetData( iState, iRow, "MN" ) ; pQuery->SetData( iZip, iRow, "55345" ) ; // Second row iRow = pQuery->AddRow() ; pQuery->SetData( iCity, iRow, "St. Paul" ) ; pQuery->SetData( iState, iRow, "MN" ) ; pQuery->SetData( iZip, iRow, "55105" ) ;
This is a deprecated function and should not be used.
This is a deprecated function and should not be used.