Menu The RecursiveIteratorIterator class
 

The RecursiveIteratorIterator class

The RecursiveIteratorIterator class is a "high-level" PHP construct. For the novice PHP programmer it is probably to be considered as an advanced topic.

The useage of this class construct on this website is under consideration as it seems a good way of building an HTML table from data in a mySQL database.

It is not the intention of this website to explain the inner workings of this class but to show how it can be used. There are many places that offer in-depth analysis and coding training in this subject.

When data is stored in an online database it is often a requirement to display the contents of a table, or a more complex query, in an HTML table to the screen.

The php.net manual says:

Can be used to iterate through recursive iterators.

The class is used in the processing of data from a MySQL table.

Top

The Class: - used to populate a HTML Table

The TableRows extends the base class RecursiveIteratorIterator

class TableRows extends RecursiveIteratorIterator {
function __construct($it) {
parent::__construct($it, self::LEAVES_ONLY);
}

function current() {
return "<td style='width:150px;border:1px solid black;'>" . parent::current(). "</td>"; }
function beginChildren() { echo "<tr>"; }

function endChildren() {
echo "</tr>" . "\n";
}
}

Extending a class

The PHP manual says:

... when extending a class, the subclass inherits all of the public and protected methods, properties and constants from the parent class. Unless a class overrides those methods, they will retain their original functionality.

class TableRows

The class TableRows, using in the script demo_db_select_pdo.php is an extended class from the class RecursiveIteratorIterator.

The class has 3 functions, __construct(), current() beginChildren() and endChildren().

Links

External Links Disabled.

tempusfugit.me.uk is a non-commercial website. No payment or benefit is gained by the placement of links toother websites.

The External link is disabled to on this page, please visit other pages

Unlike most genealogical research websites tempusfugit.me.uk does not attempt to get you to "sign-up" when you click on one of their links.

This Wikipedia link is disabled.

The link on Wikipedia was to:

External Links Disabled.

tempusfugit.me.uk is a non-commercial website. No payment or benefit is gained by the placement of links to other websites.

The External link is disabled to on this page, please visit other pages

Top

External Links - references

Site design by Tempusfugit Web Design -