Documentation automatically generated from the source-code using phpDocumentor.
Official Homepage: xao-php.sourceforge.net
XAO
Official homepage | API home | class tree: XAO | index: XAO | all elements

Class: DbToXml

Source Location: Program_Root/XAO_DbToXml.php

Class DbToXml

Class Overview

Convert a result table from an SQL query into basic XML.

Very simple conversion of SQL query results table to XML data which may then be transformed into a suitable structure. Optionally more complext usage can include the use of callback functions through the optional arguments to the constructor. See the constructor method documentation for details. This class extends DomDoc and therefore inherits all DomDoc capabilities.

Located in Program_Root/XAO_DbToXml.php [line 40]

XaoRoot
   |
   --DomDoc
      |
      --DbToXml

Properties

Methods

[ Top ]
Inherited Properties and Methods
Inherited Properties Inherited Methods

Inherited From DomDoc

DomDoc::$ndErr
DomDoc::$ndRoot
DomDoc::$objDoc
DomDoc::$objErr

Inherited From XaoRoot

XaoRoot::$arrCacheParams
XaoRoot::$fncErrCallbackFunc
XaoRoot::$idXaoNamespace
XaoRoot::$strDebugData
XaoRoot::$strError
XaoRoot::$strXaoNamespacePrefix

Inherited From DomDoc

DomDoc::DomDoc()
Constructor method
DomDoc::Arr2Atts()
Turn an associative array into attributes
DomDoc::arrNdXPath()
Return a list of nodes resulting from an XPath Query
DomDoc::blnTestElementNode()
Test if the supplied node is on object of type "domelement"
DomDoc::blnTestXmlName()
Do a reliable test for a valid element name
DomDoc::CommitToFile()
mass storage serialisation
DomDoc::ConsumeDocData()
Import well-balenced XML data to append below $this->ndRoot
DomDoc::ndAppendToNode()
quickly add a new element under an exising element node.
DomDoc::ndAppendToRoot()
quickly add a new element under the root element.
DomDoc::ndConsumeDoc()
Import a foreign PHP DOM XML document and append it below $this->ndRoot
DomDoc::ndConsumeFile()
Import an XML document from a file and append it below $this->ndRoot
DomDoc::ndConsumeFragData()
Import well-balenced XML data to append below $this->ndRoot
DomDoc::ndGetOneEl()
fetch a single element node by name
DomDoc::ndImportChildFrag()
Import a fragment from a foreign PHP DOM XML document
DomDoc::ProcessCustomTags()
Process all nodes (domelements) due for processing.
DomDoc::SetCustomTagName()
Have all elements of a specified name processed by a call-back function.
DomDoc::SetCustomTagQuery()
Use an XPath to nominate nodes for processing by a call-back function.
DomDoc::Throw()
Base error logger
DomDoc::xmlGetDoc()
Serialise and return the entire document object as stand-alone XML.
DomDoc::xmlGetFrag()
Serialise and return the entire document as an XML fragment.

Inherited From XaoRoot

XaoRoot::arrSetErrFnc()
XaoRoot::blnTestSafeName()
XaoRoot::Throw()
Generic/default error handler.

[ Top ]
Property Summary
node   $ndStub   The stub node onto which the result nodes will be grafted.
object   $objDBResult   An instance of a PEAR DB result object.
string   $strResEl   The name of the result element (root element).
string   $strRowEl   The name of the row element.

[ Top ]
Method Summary
void   DbToXml()   Constructor method
void   execute()   Convert the RDBMS data into XML elements.
void   GroupBy()   Group records in the output tree by element corresponding to column.
void   odbcToReadable()   ODBC timestamp date call-back mutator function
void   Reset()   Clean up function to flush existing data.
void   RowConstructor()   Row Contructor
void   RowDestructor()   Row Destructor
void   unixTsToReadable()   unix timestamp date call-back mutator function

[ Top ]
Properties
node   $ndStub [line 52]

The stub node onto which the result nodes will be grafted.

This is used by the execute() method to append child nodes to. Unless a stub node is specified in the constructor, it will be assigned the instance DomDoc::ndRoot

API Tags:
Access:  public


[ Top ]
object   $objDBResult [line 76]

An instance of a PEAR DB result object.

API Tags:
Access:  public


[ Top ]
string   $strResEl = "result" [line 60]

The name of the result element (root element).

API Tags:
Access:  public


[ Top ]
string   $strRowEl = "row" [line 68]

The name of the row element.

API Tags:
Access:  public


[ Top ]
Methods
Constructor DbToXml  [line 113]

  void DbToXml( object An &$objDBResult, [array $arrCallBacks = array()], [object a $objDocRef = null], [object a $ndStub = null]  )

Constructor method

Perform requirements checks and initialised resources.

Parameters:
object An   &$objDBResult:  instance of a PEAR DB result object or a 2d associative array.
array   $arrCallBacks:  An associative array mapping result column names to methods (call back functions) of the class.
object a   $objDocRef:  reference to an existing DOM document
object a   $ndStub:  DOM node in the referenced document where the results from this calss will be appended.


[ Top ]
execute  [line 164]

  void execute( )

Convert the RDBMS data into XML elements.

Run the fetch method on the result object to obtain the result data in a 2D array. Iterate over this 2D array to first obtain the rows and then the fields which are created and appended as elements using DOM XML methods.



[ Top ]
GroupBy  [line 251]

  void GroupBy( string $strColName  )

Group records in the output tree by element corresponding to column.

This is a very handy way to quickly group output elements by a selected element.

Parameters:
string   $strColName:  name of the column used for grouping


[ Top ]
odbcToReadable  [line 342]

  void odbcToReadable( object a &$objDOM, node &$ndField, string $odbcTs  )

ODBC timestamp date call-back mutator function

This call-back function is placed here for convenience and can be used to produce create a unix timestamp from an ODBC compliant timestamp. This unix timestap is then sent to $this->unixTsToReadable where nice attributes are added :)

Parameters:
object a   &$objDOM:  reference to the current PHP DOM XML object instance
node   &$ndField:  a reference to the element node representing a field
string   $odbcTs:  a copy of the text content that would normally be assigned to this field elemeent.

API Tags:
Access:  public


[ Top ]
Reset  [line 263]

  void Reset( )

Clean up function to flush existing data.

Calling this function is needed if the constructor is to be called more than once.



[ Top ]
RowConstructor  [line 283]

  void RowConstructor( object a &$objDoc, node &$ndRow  )

Row Contructor

This abstract method may be overwritten by the child class in order to perform an operation just _prior_ to the execution of a row in the execute() method of this class

Parameters:
object a   &$objDoc:  reference to the current PHP DOM XML object instance
node   &$ndRow:  a reference to the element node representing a row

API Tags:
Access:  public


[ Top ]
RowDestructor  [line 297]

  void RowDestructor( object a &$objDoc, node &$ndRow  )

Row Destructor

This abstract method may be overwritten by the child class in order to perform an operation just _after_ the execution of a row in the execute() method of this class

Parameters:
object a   &$objDoc:  reference to the current PHP DOM XML object instance
node   &$ndRow:  a reference to the element node representing a row

API Tags:
Access:  public


[ Top ]
unixTsToReadable  [line 315]

  void unixTsToReadable( object a &$objDoc, node &$ndField, string $intTs  )

unix timestamp date call-back mutator function

This call-back function is placed here for convenience and can be used to produce an element with a more convenient schema for representing a date from a unix timestamp. It also provides a useful example of the call-back capability of this class. What it does is add a set of attributes to the element in context which each represent a conventional date component.

Parameters:
object a   &$objDoc:  reference to the current PHP DOM XML object instance
node   &$ndField:  a reference to the element node representing a field
string   $intTs:  a copy of the text content that would normally be assigned to this field elemeent.

API Tags:
Access:  public


[ Top ]

Documentation generated on Tue, 23 Sep 2003 18:33:55 +1000 by phpDocumentor 1.2.2