CCFXQuery Class

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 members

virtual int AddRow()

CCFXQuery::AddRow adds a row to a query.

virtual int AddRow()  virtual CCFXStringSet* GetColumns

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

virtual LPCSTR GetData( int iRow, int iColumn )

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

virtual LPCSTR GetName()

CCFXQuery::GetName retrieves the name of a query.

virtual int GetRowCount()

CCFXQuery::GetRowCount retrieves the number of rows in a query.

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

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

virtual void SetQueryString( LPCSTR lpszQuery )

CCFXQuery::SetQueryString sets a query string that displays with query debug output.

virtual void SetTotalTime( DWORD dwMilliseconds )

CCFXQuery::SetTotalTime sets the time that was required to process the query (used for debug output).

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. The memory allocated for the returned string set is freed automatically by ColdFusion after the request is completed.

Example

The following example retrieves 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

Retrieves 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 CCFXQuery::GetRowCount. You can determine the number of columns in a query by retrieving the list of columns using CCFXQuery::GetColumns and then calling CCFXStringSet::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)
lColumn
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

LPCSTR 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 CCFXQuery::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)
lColumn
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" ) ;

CCFXQuery::SetQueryString

This is a deprecated function and should not be used.

CCFXQuery::SetTotalTime

This is a deprecated function and should not be used.



Banner.Novgorod.Ru