Save as Word Document | Find | English | Portugues(Brasil)

Database Access
The IIterator interface and the objects for standardized data access.

The standardized method for accessing any data source through the IIterator interface and the objects for accessing data existing in XLMNuke.

Table of contents
1. Configuring the Connection to the Database
2. Connecting through the DBDataSet
3. The IIterator interface and the objects for standardized data access.

On this page
The IIterator Interface
The SingleRow Object
Classes for data access on XMLNuke


The IIterator Interface

In XMLNuke, all of the structures for accessing data use an identical method to iterate through their entries. The origin does not matter, whether it is XML, DataBase, .CSV files, etc,; all of them implement the IIterator interface. The interface has the following methods:

  • hasNext() - returns true or false and indicates if there are still files in the structure that are being iterated.
  • moveNext() - returns a SingleRow type object that represents the fields and data of an entry

All of the objects in XMLNuke that manipulate or use a data source receive an IIterator as a standard way to iterate these data.

The SingleRow Object

The SingleRow object represents an "entry", or a group of data from the same instance. Each entry iterated with the moveNext() method of the IIterator interface generates a SingleRow type object. The SingleRow object basically uses the following methods:

  • getField(name) - obtain the value of a specific field
  • getFieldArray(name) - obtain an array with all of the data in the "name" field for that entry. It's important to note that the SingleRow object is in fact an abstraction for an XML and not necessarily for a relational database. This way, a field may, in some cases, have more than one value.
  • getFieldNames() - Obtains the names of all the fields.
  • getDomObject() - Obtains the DOM object to be manipulated
Important note: The SingleRow object has methods to modify the values, add fields or remove fields; however, it is only sensitive to an AnyDataSet object.

Classes for data access on XMLNuke

XMLNuke has several classes to access and manipulate data. Even though the data sources exist in various formats, the programmer only needs to know the IIterator interface and the SingleRow object. The data sources are listed as follows:
Class Data Source Acess Xmlnuke Engine Notes
AnyDataSet XML Pre-Defined Reading/Writing PHP5/CSharp Available in all versions of XMLNuke. It can serve as a small data repository and does not require other configurations. It does not serve for concurrent access and access to many entries.
DBDataSet Relational DataBase Reading/Writing PHP5/CSharp The supported databases and versons may be accessed here. The reading and writing method should be done through SQL commands. It supports transactions and parameters.
ArrayDataSet Array Reading PHP5/CSharp In the CSharp version, the class is capable of iterating an object of the NameValueCollection type. In the PHP version, it iterates any array.
DSDataSet DataSet .NET Reading CSharp It is capable of iterating in a standardized way a DataSet in .NET
SocketDataSet Stream text in Socket Reading PHP5 It connects through fsocketopen() and reads a data stream. A line and column separator must be supplied to determine the entries and columns
TextFileDataSet Text Delimeted Reading PHP5/CSharp Open a text document and allows it to iterate through the IIterator. The line break is the entry delimitor, and to delimit the fields a regular expression must be provided. The object by default has a regular expression for .CSV documents generated by Excel.
XmlDataSet XML Reading PHP5/CSharp Allows an XML document to be iterated in a standardized way. An XPATH should be provided to determine the entries and an XPATH collection (related to the XPATH of the line) should be provided to determine the fields. Attributes or text nodes can be provided.

Previous
Connecting through the DBDataSet