Exemple #1
0
 /**
  * Get all statistics associated with a particular hole, restricted by a pager
  *
  * @static
  * @param int $id  File ID
  * @param DH_Pager $pager Pager object
  * @return array Array of DH_Access objects
  **/
 function get_by_hole($id, &$pager)
 {
     global $wpdb;
     $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM @access INNER JOIN @files ON @access.file_id=@files.id AND @files.hole_id={$id}" . $pager->to_limits();
     $sql = str_replace('@', $wpdb->prefix . 'drainhole_', $sql);
     $rows = $wpdb->get_results($sql, ARRAY_A);
     $pager->set_total($wpdb->get_var("SELECT FOUND_ROWS()"));
     $data = array();
     if ($rows) {
         foreach ($rows as $row) {
             $data[] = new DH_Access($row);
         }
     }
     return $data;
 }
Exemple #2
0
 /**
  * Returns all files in a given hole, restricted by a pager
  *
  * @static
  * @param int $id Hole ID
  * @param DH_Pager $pager A pager object
  * @return array Array of DH_File objects
  **/
 function get_by_hole($id, &$pager)
 {
     global $wpdb;
     $sql = "SELECT SQL_CALC_FOUND_ROWS @files.*,@version.version,@version.created_at FROM @files LEFT JOIN @version ON @files.version_id=@version.id";
     $sql .= $pager->to_limits("@files.hole_id='{$id}'", array('file'));
     $sql = str_replace('@', "{$wpdb->prefix}drainhole_", $sql);
     $rows = $wpdb->get_results($sql, ARRAY_A);
     $pager->set_total($wpdb->get_var("SELECT FOUND_ROWS()"));
     $data = array();
     if ($rows) {
         foreach ($rows as $row) {
             $data[] = new DH_File($row);
         }
     }
     return $data;
 }