Mantis - Quercus
|
|||||
Viewing Issue Advanced Details | |||||
|
|||||
ID: | Category: | Severity: | Reproducibility: | Date Submitted: | Last Update: |
3822 | block | always | 12-20-09 19:46 | 12-21-09 05:23 | |
|
|||||
Reporter: | domdorn | Platform: | |||
Assigned To: | OS: | ||||
Priority: | normal | OS Version: | |||
Status: | new | Product Version: | 4.0.2 | ||
Product Build: | Resolution: | open | |||
Projection: | none | ||||
ETA: | none | Fixed in Version: | |||
|
|||||
Summary: | 0003822: Variable scoping issues in loops!!!! | ||||
Description: |
I have lots of code like this: while(list($dnow, $nusernr, $stitle, $stext, $nuserguestbooknr,$nstatusnr) = $rSQLGetEntries->fetchRow() ) { include("$sDocumentRoot/ly/tmpl/elements/dsp_GuestbookEntry.php"); unset($dnow, $nusernr, $stitle, $stext, $nuserguestbooknr,$nstatusnr); } where $rSQLGetEntries is a Pear::DB Object and fetchRow() is a method, returning an array (see http://pear.php.net/manual/en/package.database.db.db-result.fetchrow.php [^] ) this code does not work, because the list expression is not implemented correctly OR the scoping of variables in Loops is broken! I've narrowed it down to something like this (10 is the correct number of rows returned) for($i = 0; $i < 10; $i++) { $res = $rSQLGetEntries->fetchRow(); print_r($res); echo "<hr/>"; } this correctly executes print_r on each of the 10 rows... however, as soon as I do this: for($i = 0; $i < 10; $i++) { $res = $rSQLGetEntries->fetchRow(); print_r($res); echo "<hr/>"; $dnow = $res[0]; } the code stops after the first loop execution |
||||
Steps To Reproduce: | |||||
Additional Information: | |||||
Relationships | |||||
Attached Files: |
Notes | |||||
|
|||||
|
|