CFDBWpdbResultIterator

The WordPress Core CFDBWpdbResultIterator class.

Defined (1)

The class is defined in the following location(s).

/CFDBWpdbResultIterator.php  
  1. class CFDBWpdbResultIterator extends CFDBAbstractQueryResultsIterator { 
  2.  
  3. /** 
  4. * @var array[associative array] 
  5. */ 
  6. var $wpdbResults; 
  7.  
  8. /** 
  9. * @var int 
  10. */ 
  11. var $wpdbIdx = 0; 
  12.  
  13. /** 
  14. * @var int 
  15. */ 
  16. var $wpdbLen = 0; 
  17.  
  18. /** 
  19. * Execute the query 
  20. * @param $sql string query 
  21. * @param $queryOptions array associative 
  22. * @return void 
  23. */ 
  24. public function queryDataSource(&$sql, $queryOptions) { 
  25. global $wpdb; 
  26. $this->wpdbResults = 
  27. $wpdb->get_results($sql, ARRAY_A); 
  28. $this->wpdbLen = $wpdb->num_rows; 
  29.  
  30. /** 
  31. * Get the next row from query results 
  32. * @return array associative 
  33. */ 
  34. public function fetchRow() { 
  35. if ($this->wpdbIdx < $this->wpdbLen) { 
  36. return $this->wpdbResults[$this->wpdbIdx++]; 
  37. return false; 
  38.  
  39. /** 
  40. * If you do not iterate over all the rows returned, be sure to call this function 
  41. * on all remaining rows to free resources. 
  42. * @return void 
  43. */ 
  44. public function freeResult() { 
  45. global $wpdb; 
  46. $wpdb->flush();