0";
if ($v_commend=="ok") $whereStr.=" and d.v_commend>0";
if ($v_recycled=="ok") $whereStr.=" and d.v_recycled=1";
if ($repeat=="ok") {
$dsql->SetQuery("select v_name from pi_data where v_recycled=0 group by v_name having count(*)>1");
$dsql->Execute('video_have');
$repeatsql="";
while($rowh=$dsql->GetObject('video_have'))
{
$repeatsql.="or d.v_name='$rowh->v_name' ";
}
$whereStr.=rtrim(" and 1=2 or ".ltrim($repeatsql,"or"),"or ");
}
if (!empty($type)) $whereStr.=" and d.tid in (".getTypeId($type).")";
if (!empty($topic)) $whereStr.=" and d.v_topic =".$topic;
if (!empty($keyword)) $whereStr.=" and d.v_name like '%".$keyword."%' or d.v_actor like '%".$keyword."%' ";
if (!empty($playfrom)) $whereStr.=" and p.body like '%".$playfrom."$$%' ";
$whereorder = str_replace("where order","order",str_replace("where and","and",$whereStr.$orderStr));
if (!empty($playfrom)){
$csqlStr="select count(*) as dd from `pi_data` d left join `pi_playdata` p on p.v_id=d.v_id where d.v_recycled=0 ".$whereorder;
if ($v_recycled=="ok")$csqlStr="select count(*) as dd from `pi_data` d left join `pi_playdata` p on p.v_id=d.v_id where d.v_recycled=1 ".$whereorder;
}else{
$csqlStr="select count(*) as dd from `pi_data` d where d.v_recycled=0 ".$whereorder;
if ($v_recycled=="ok")$csqlStr="select count(*) as dd from `pi_data` d where d.v_recycled=1 ".$whereorder;
}
$row = $dsql->GetOne($csqlStr);
if(is_array($row)){
$TotalResult = $row['dd'];
}else{
$TotalResult = 0;
}
$TotalPage = ceil($TotalResult/$numPerPage);
if ($page>$TotalPage) $page=$TotalPage;
$limitstart = ($page-1) * $numPerPage;
if($limitstart<0) $limitstart=0;
$sqlStr="select d.v_id,d.v_name,d.v_hit,0,d.v_state,d.tid,d.v_topic,d.v_addtime,d.v_commend,p.body as v_playdata,t.tname from pi_data d left join `pi_type` t on t.tid=d.tid left join `pi_playdata` p on p.v_id=d.v_id where d.v_recycled=0 ".$whereorder." limit $limitstart,$numPerPage";
if ($v_recycled=="ok") $sqlStr="select d.v_id,d.v_name,d.v_hit,0,d.v_state,d.tid,d.v_topic,d.v_addtime,d.v_commend,p.body as v_playdata,t.tname from pi_data d left join `pi_type` t on t.tid=d.tid left join `pi_playdata` p on p.v_id=d.v_id where 1=1 ".$whereorder." limit $limitstart,$numPerPage";
//echo $sqlStr;
?>