flush
[mdref/mdref-pq-gateway] / pq-gateway / pq / Gateway / Table / Attributes / getIterator.md
1 # ArrayIterator pq\Gateway\Table\Attributes::getIterator()
2
3 Implements IteratorAggregate.
4
5 ## Params:
6
7 None.
8
9 ## Returns:
10
11 ArrayIterator, columnd list (indexed by column number **and** name).
12
13 ## Example:
14
15 <?php
16
17 use pq\Gateway\Table;
18
19 class ColNameIterator extends FilterIterator {
20 public function __construct(Table\Attributes $attrs) {
21 parent::__construct($attrs->getIterator());
22 }
23 public function accept() {
24 return !is_numeric($this->key());
25 }
26 }
27
28 $table = new pq\Gateway\Table("account");
29 $attrs = $table->getAttributes();
30 foreach (new ColNameIterator($attrs) as $col => $att) {
31 printf("%10s: %s\n", $col, http_build_query($att, null, ", "));
32 }
33
34 ?>
35
36 Yields:
37
38 id: index=1, name=id, type=2950, hasdefault=1, nullable=0
39 password: index=2, name=password, type=1042, hasdefault=0, nullable=1
40 name: index=3, name=name, type=1043, hasdefault=0, nullable=1