Monday, 15 February 2010

php - Mysqli while loop returns empty array on obviously non-empty resultset -



php - Mysqli while loop returns empty array on obviously non-empty resultset -

in php, i'm using mysqli, fetch resultset database. upon fetching resultset, hand off function returns object. given resultset:

why function:

/** * @param resource|\mysqli_result $result * @return array|bool */ public static function getobjectarray($result) { if($result === false) { homecoming false; } $func = ((gettype($result) === 'resource') ? 'mysql' : 'mysqli') . '_fetch_object'; $array = array(); while($row = $func($result)) { $array[] = $row; } homecoming $array; }

return empty array. when debugging, skips body of while loop. function has worked without problem in hundreds of other places, particular resultset, craps out.

thanks in advance.

i don't know details on it, appears resultset sort of implicit pass reference. broke downwards part breaking , ran tests, , if pass resultset parameter function, sets data_seek of original end. reset on resultset pass in , works fine. if has insight happening, i'd love have deeper understanding.

thanks

php mysql mysqli

No comments:

Post a Comment