• $a = new CFDBFormIterator();
    $b = new CFDBFormIterator();

    Scenario 1:
    $a->export(‘Form1’, array(‘filter’=>’Post_ID>0||Post_ID<999999’));
    // Collects 2 rows
    while($rowA = $a->nextRow())
    {
    $b->export(‘Form1’, array(‘filter’=>’Post_ID>0||Post_ID<999999’));
    while($rowB = $b->nextRow())
    {
    (Do something…)
    }
    }
    Result => Only the first row of $a is processed and the while loop stops at one iteration.

    Scenario 2:
    $a->export(‘Form1’, array());
    // Collects 2 rows
    while($rowA = $a->nextRow())
    {
    $b->export(‘Form1’, array(‘filter’=>’Post_ID>0||Post_ID<999999’));
    while($rowB = $b->nextRow())
    {
    (Do something…)
    }
    }
    Result => All 2 rows of $a is processed. While loop does 2 iterations because there are 2 rows in $a.

    Question:
    Why is the behavior between scenario 1 and scenario 2 different? The only different is the filter process in scenario 1. In scenario 1, $a actually has both rows. But the second row vanishes after $b->export line. Where as in scenario 2 nothing vanishes.

    https://www.ads-software.com/plugins/contact-form-7-to-database-extension/

  • The topic ‘Nested Loop Loses Row’ is closed to new replies.