An abstract class that represents a query used or created by a ColdFusion Extension (CFX). Queries contain one or more columns of data that extend over a varying number of rows.

Class methods

virtual int AddRow()

:AddRow adds a row to a query.

virtual CCFXStringSet* GetColumns

:GetColumns retrieves a list of a query's column names.

virtual LPCSTR GetData( int iRow, int iColumn )

:GetData retrieves a data element from a row and column of a query.

virtual LPCSTR GetName()

:GetName retrieves the name of a query.

virtual int GetRowCount()

:GetRowCount retrieves the number of rows in a query.

virtual void SetData( int iRow, int iColumn, LPCSTR lpszData )

:SetData sets a data element within a row and column of a query.

virtual void SetQueryString( LPCSTR lpszQuery )

This function is deprecated. It might not work, and might cause an error, in later releases.

virtual void SetTotalTime( DWORD dwMilliseconds )

This function is deprecated. It might not work, and might cause an error, in later releases.

CCFXQuery::AddRow

Syntax

int CCFXQuery::AddRow(void)

Description

Add a row to the query. Call this function to append a row to a query.

Returns

Returns the index of the row that was appended to a query.

Example

The following example shows the addition of two rows to a three-column ('City', 'State', and 'Zip') query:

// 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" ) ;

CCFXQuery::GetColumns

Syntax

CCFXStringSet* CCFXQuery::GetColumns(void)

Description

Retrieves a list of the column names contained in a query.

Returns

Returns an object of CCFXStringSet class that contains a list of the columns in the query. ColdFusion automatically frees the memory that is allocated for the returned string set, after the request is completed.

Example

The following example gets the list of columns, 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( " " ) ;
}

CCFXQuery::GetData

Syntax

LPCSTR CCFXQuery::GetData(int iRow, int iColumn)

Description

Gets a data element from a row and column of a query. Row and column indexes begin with 1. You can determine the number of rows in a query by calling :GetRowCount. You can determine the number of columns in a query by retrieving the list of columns using :GetColumns, and then calling :GetCount on the returned string set.

Returns

Returns the value of the requested data element.

Parameters

Parameter

Description

iRow

Row to retrieve data from (1-based)

iColumn

Column to retrieve data from (1-based)

Example

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>" ) ;
}

CCFXQuery::GetName

Syntax

LPCSTR CCFXQuery::GetName(void)

Description

Returns the name of a query.

Example

The following example retrieves the name of a query and writes it back to the user:

CCFXQuery* pQuery = pRequest->GetQuery() ;
pRequest->Write( "The query name is: " ) ;
pRequest->Write( pQuery->GetName() ) ;

CCFXQuery::GetRowCount

Syntax

int CCFXQuery::GetRowCount(void)

Description

Returns the number of rows contained in a query.

Example

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 ) ;

CCFXQuery::SetData

Syntax

void CCFXQuery::SetData(int iRow, int iColumn, LPCSTR lpszData)

Description

Sets a data element within a row and column of a query. Row and column indexes begin with 1. Before calling SetData for a given row, call :AddRow and use the return value as the row index for your call to SetData.

Parameters

Parameter

Description

iRow

Row of data element to set (1-based)

iColumn

Column of data element to set (1-based)

lpszData

New value for data element

Example

The following example shows the addition of two rows to a three-column ('City', 'State', and 'Zip') query:

// 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 work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy