X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fpq-gateway;a=blobdiff_plain;f=lib%2Fpq%2FGateway%2FTable%2FAttributes.php;h=0ba2d707b2df0e23ce87280a6cc344fa1a16324d;hp=39c55c948e00fbdfddb7058780f275c81c321411;hb=ccdcd2977c8bdc7c74b89b2fb7c2ea46479692b8;hpb=80c4d645e1650304b1dbcae85dbf17a6593896e4 diff --git a/lib/pq/Gateway/Table/Attributes.php b/lib/pq/Gateway/Table/Attributes.php index 39c55c9..0ba2d70 100644 --- a/lib/pq/Gateway/Table/Attributes.php +++ b/lib/pq/Gateway/Table/Attributes.php @@ -17,7 +17,7 @@ const ATTRIBUTES_SQL = << 0 SQL; -class Attributes +class Attributes implements \IteratorAggregate { /** * @var array @@ -29,14 +29,14 @@ class Attributes */ function __construct(Table $table) { $cache = $table->getMetadataCache(); - if (!($this->columns = $cache->get("$table#attributes"))) { + if (!($this->columns = $cache->get("$table:attributes"))) { $table->getQueryExecutor()->execute( new \pq\Query\Writer(ATTRIBUTES_SQL, array($table->getName())), function($result) use($table, $cache) { foreach ($result->fetchAll(\pq\Result::FETCH_OBJECT) as $c) { $this->columns[$c->index] = $this->columns[$c->name] = $c; } - $cache->set("$table#attributes", $this->columns); + $cache->set("$table:attributes", $this->columns); } ); } @@ -69,4 +69,12 @@ class Attributes } return $this->columns[$c]; } + + /** + * Implements \IteratorAggregate + * @return \ArrayIterator + */ + function getIterator() { + return new \ArrayIterator($this->columns); + } }