Location: PHPKode > scripts > flashPash > flashpash/flashPash.recordset.php
<?php

/*==-==-==-==-==-==-==-==-==-==-==-==-==-==-==+
 |       flashPash PHP recordset include      |
 +==-==-==-==-==-==-==-==-==-==-==-==-==-==-==+
 |              version 1.0 *RC1*             |
 |                                            |
 | last update on 2003-06-21 by si*sshnug.com |
 |                                            |
 |   Copyright (c) 2002-2003, Simon Mckenna   |
 |            All rights reserved             |
 +==-==-==-==-==-==-==-==-==-==-==-==-==-==-==*/

/* static properties for recordset */
define( 'FP_RECORDSET_TABLE_NAME', 'table' );

function _buildRecordsetMetaResult( &$fp, &$tree, &$dataPacketElement )
{
	$mapElement =& $dataPacketElement->addChild( FP_ROW_NODE );

	/* loop through all fields in first row to build field map */
	$fieldCount = $fp->_result->FieldCount();
	if ( $fieldCount == 0 )
		return $fp->_logError( FP_ERROR_META, 'no fields return from query', true );

	for ( $colPos = 0; $colPos < $fieldCount; $colPos++ )
	{
		$fieldObject = $fp->_result->FetchField( $colPos );
		$fp->_debugLog( 'meta-data', $fieldObject );

		/* have to extract table and field names from meta-data, extraction depends on db meta abilities */
		if ( strpos( strtoupper( $fp->_SQL[ $fp->_qri ] ), FP_SQL_ALIAS ) === false )
		{
			if ( !empty( $fieldObject->table ))
				$tableName = $fieldObject->table;
			else
				return $fp->_logError( FP_ERROR_META, 'unable to extact table name from field', true, $fieldObject->name );
			$fieldName = $fieldObject->name;
		}
		else
		{
			$tableName = substr( $fieldObject->name, 0, strpos( strtoupper( $fieldObject->name ), FP_SQL_ALIAS ));
			$fieldName = substr( $fieldObject->name, strpos( strtoupper( $fieldObject->name ), FP_SQL_ALIAS ) + strlen( FP_SQL_ALIAS ));
		}

		$attributes = array();

		$attributes[ FP_RECORDSET_TABLE_NAME ] = $tableName;
		$attributes[ FP_FIELD_NAME ]       = $fieldName;
		$attributes[ FP_FIELD_TYPE ]       = $fp->_result->MetaType( $fieldObject->type );
		
		if (( isset( $fieldObject->primary_key ) && ( $fieldObject->primary_key )) ||
			  ( isset( $fieldObject->multiple_key ) && ( $fieldObject->multiple_key )))
			$attributes[ FP_FIELD_KEY ] = 'true';
			
		$fieldElement =& $mapElement->addChild( FP_FIELD_NODE, NULL, $attributes );
	}
	return true;
}

function _convertRecordsetFieldType( &$fp, $type )
{
	/* recordset data source types match ADOdb field types, so just check for validity */
	switch ( $type )
	{
		case FP_ADODB_CHARACTER : return FP_ADODB_CHARACTER; break;
		case FP_ADODB_CLOB      : return FP_ADODB_CLOB;      break;
		case FP_ADODB_DATE      : return FP_ADODB_DATE;      break;
		case FP_ADODB_TIMESTAMP : return FP_ADODB_TIMESTAMP; break;
		case FP_ADODB_BOOLEAN   : return FP_ADODB_BOOLEAN;   break;
		case FP_ADODB_NUMERIC   : return FP_ADODB_NUMERIC;   break;
		case FP_ADODB_INTEGER   : return FP_ADODB_INTEGER;   break;
		case FP_ADODB_COUNTER   : return FP_ADODB_COUNTER;   break;
		case FP_ADODB_BLOB      : return FP_ADODB_BLOB;      break;
		default : return $fp->_logError( FP_ERROR_PARSING_XML, 'unknown recordset field type', true, $type );
	}
}

?>
Return current item: flashPash