Okay, I'm getting this error in a class I've written. I can't explain
it.
Right off the bat let me mention that I'm using PHP5, and my
"collection" class implements IteratorAggregate.
The code flow is essentially this:
I use ADODB to select a bunch of rows from a database
"SELECT * FROM table ORDER BY context"
That's it. I get the rows back okay. Then I'm iterating through the
record set, adding Objects to a collection
while (!$res->EOF)
{
$f = $res->fields;
$collection->Add(new MyObject($f['name'], $f['position'],
$f['context']));
$res->MoveNext();
}
The Object is being created perfectly, I've checked.
The collection's Add() method is something like:
public function Add($object)
{
$this->arr_objects[intval($object->position)] =
$object; < THIS LINE IS THE PROBLEM
$this->count++;
}
And that's it. Pretty standard stuff so far.
Now here's the problem. When I'm debugging this thing, the line that
I've marked doesn't actually add anything to the array. If I try to view
the contents of the array, it gives me a "cannot find element in
variable" error. Later, when I iterate through it, two elements are
outputted (don't ask me why, my iterator is perfect, I checked). Can
someone shed some light on this? It's pretty annoying...in the mean
time, I'll just use arrays.
Thanks for your time,
Scott Hyndman
[EMAIL PROTECTED]