|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-10-06 06:55 UTC] simonslaws at googlemail dot com
Description:
------------
I am trying to us an iterator to iterator across an SDO many valued property.
$itemIterator = $rss->channel->item->getIterator();
while ( $iterator->valid() && $item == null ) {
if ($itemIterator->current()->title == $title ) {
$item = $itemIterator->current();
}
$iterator->next();
}
When running this I get:
[Sun Oct 01 11:21:18 2006] [error] [client 127.0.0.1] PHP Fatal error:
Call to undefined method SDO_DataObjectList::getIterator() in
C:\\simon\\Projects\\Eclipse3.2\\ajax-rss\\sdoajax.php on line 70
Reproduce code:
---------------
With array.xsd
==============
<complexType name="ArrayContainerType">
<sequence>
<element name="Array" type="string" minOccurs="1" maxOccurs="unbounded"/>
</sequence>
</complexType>
<element name="ArrayContainer" type="tns:ArrayContainerType"/>
and code
========
<?php
$xmldas = SDO_DAS_XML::create('array.xsd');
$array_doc = $xmldas->createDocument();
$array_container = $array_doc->getRootDataObject();
$array_container->Array[] = "arrayitem1";
$array_container->Array[] = "arrayitem2";
$array_container->Array[] = "arrayitem3";
$itemIterator = $array_container->getIterator();
while ( $iterator->valid() && $item == null ) {
echo "An Item ";
print_r($itemIterator->current());
$iterator->next();
}
?>
Expected result:
----------------
Print out the three elements of the array
Actual result:
--------------
The filename, directory name, or volume label syntax is incorrect.
PHP Fatal error: Call to undefined method SDO_DataObjectImpl::getIterator() in
C:\simon\Projects\Eclipse3.2\phpscripts\peclx.php on line 11
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
Thank you for taking the time to write to us, but this is not a bug. SDO_DataObject doesn't have a getIterator method. There are SPL classes which let you do this. You can use an IteratorIterator (really) to get a userland view into the iteration functions, for example: $iter = new IteratorIterator($do, 'SDO_DataObjectImpl'); (Note that you have to use the implementation class name, even though the SDO_DataObject interface does itself extend Traversable, but SPL wants the name of a concrete class.) Once you have your iterator you can then do all the iterator operations on it: rewind(), key(), current(), next(), and valid(). A refinement would be to add an SDO_Iterator class (c.f. SimpleXMLIterator) as a subclass of IteratorIterator, which would work with all the Traversable SDO objects (DataObject, List, Sequence). This would implement getIterator() and look a bit nicer than the above. I'll put this on the wish list.