0) { $where = join(" AND ", $where); $sql = $selectorCount." FROM ".$fromTable." WHERE ".$where; $sqlTotalDisplayRows = $sql; $sql = $selectorRows." FROM ".$fromTable." WHERE ".$where." ORDER BY ".$orderby; //limit the results returned. if ($displayLength !== -1) { $sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength; } } else { $sql = $selectorRows." FROM ".$fromTable." ORDER BY ".$orderby; //limit the results returned. if ($displayLength !== -1) { $sql .= " OFFSET ".$data["iDisplayStart"]." LIMIT ".$displayLength; } } try { $r = $con->query($sqlTotalRows); $totalRows = $r->fetchColumn(0); if (isset($sqlTotalDisplayRows)) { $r = $con->query($sqlTotalDisplayRows); $totalDisplayRows = $r->fetchColumn(0); } else { $totalDisplayRows = $totalRows; } $r = $con->query($sql); $r->setFetchMode(PDO::FETCH_ASSOC); $results = $r->fetchAll(); // we need to go over all items and fix length for playlist // in case the playlist contains dynamic block foreach ($results as &$r) { //this function is also called for Manage Users so in //this case there will be no 'ftype' if (isset($r['ftype'])) { if ($r['ftype'] == 'playlist') { $pl = new Application_Model_Playlist($r['id']); $r['length'] = $pl->getLength(); } else if ($r['ftype'] == "block") { $bl = new Application_Model_Block($r['id']); if ($bl->isStatic()) { $r['bl_type'] = 'static'; } else { $r['bl_type'] = 'dynamic'; } $r['length'] = $bl->getLength(); } } } } catch (Exception $e) { Logging::debug($e->getMessage()); } return array( "sEcho" => intval($data["sEcho"]), "iTotalDisplayRecords" => intval($totalDisplayRows), "iTotalRecords" => intval($totalRows), $dataProp => $results ); } }