国产亚洲精品自拍,亚洲va在线va天堂va不卡下载,亚洲av中文无码字幕色本,国产精品久久国产精品},韩国激情一区二区无码在线},亚洲人成网站www

信息動(dòng)態(tài)

網(wǎng)站設(shè)計(jì)是技術(shù)與創(chuàng)意的完美融合!

技術(shù)資訊

dede:sql 調(diào)用flag att文檔屬性 翻頁(yè)

2014-07-25 12:40:12

dede:sql標(biāo)簽分頁(yè) dede:sql 調(diào)用flag/att文檔屬性 翻頁(yè),青島網(wǎng)站建設(shè)中有時(shí)候需要在頁(yè)面上通過(guò)sql語(yǔ)句調(diào)用其他數(shù)據(jù)庫(kù)或者其他表的數(shù)據(jù),例如在當(dāng)前列表頁(yè)調(diào)用一個(gè)特定文檔屬性的文章列表,再加上翻頁(yè),效果就不好處理了,需要對(duì)arc.listview.class.php進(jìn)行改造,方法在這篇文章有描述  DEDE{dede:sql}標(biāo)簽如何分頁(yè) ,下文最后會(huì)在描述一遍,改造完著文件后,就可以這樣調(diào)用了。

{dede:listsql pagesize='1' sql="select a.id as aid, a.description as description, t.id as tid,typeid,senddate,title,litpic,ismake,arcrank,namerule,typedir From ltd_archives a, ltd_arctype t where a.typeid = t.id and FIND_IN_SET('f', flag)>0" }

<li><a href="[field:array runphp='yes']@me=GetFileUrl(@me['aid'],@me['typeid'],@me['senddate'],@me['title'],@me['ismake'],@me['description'],@me['arcrank'],@me['namerule'],@me['typedir'],@me['money']);[/field:array]"><img src="[field:litpic/]" width="304" height="158" /><h4>[field:title/]</h4>

<h5>[field:senddate function='strftime("%Y-%m-%d",@me)'/]</h5>

<p>[field:description/]...</p></a>

</li>

{/dede:listsql}

                            <div class="page">

<!--分頁(yè)-->

{dede:pagelist listsize='1' listitem='pre pageno next'/}

 

</div>

 

 

arc.listview.class.php進(jìn)行改造,方法:

找到:

if(!is_object($ctag))
  {
   $ctag = $this->dtp->GetTag("list");
  }

這一段,在其后添加如下代碼:
  if(!is_object($ctag))
  {
   $ctag = $this->dtp->GetTag("listsql");
   if (is_object($ctag))
   {
    $cquery = $ctag->GetAtt("sql");
    $cquery = preg_replace("/SELECT(.*?)FROM/is", " SELECT count(*) as dd FROM ", $cquery);
    $cquery = preg_replace("/ORDER(.*?)SC/is", "", $cquery);
    $row = $this->dsql->GetOne($cquery);
    if(is_array($row))
    {
     $this->TotalResult = $row['dd'];
    }
    else
    {
     $this->TotalResult = 0;
    }
   }
  }
  //end

然后找到:

if($ctag->GetName()=="list")
   {
    $limitstart = ($this->PageNo-1) * $this->PageSize;
    $row = $this->PageSize;
    if(trim($ctag->GetInnerText())=="")
    {
     $InnerText = GetSysTemplets("list_fulllist.htm");
    }
    else
    {
     $InnerText = trim($ctag->GetInnerText());
    }
    $this->dtp->Assign($tagid,
    $this->GetArcList(
    $limitstart,
    $row,
    $ctag->GetAtt("col"),
    $ctag->GetAtt("titlelen"),
    $ctag->GetAtt("infolen"),
    $ctag->GetAtt("imgwidth"),
    $ctag->GetAtt("imgheight"),
    $ctag->GetAtt("listtype"),
    $ctag->GetAtt("orderby"),
    $InnerText,
    $ctag->GetAtt("tablewidth"),
    $ismake,
    $ctag->GetAtt("orderway")
    )
    );
   }

這一段,在其后添加如下代碼:


   else if($ctag->GetName()=="listsql")
   {
    $limitstart = ($this->PageNo-1) * $this->PageSize;
    $row = $this->PageSize;
    if(trim($ctag->GetInnerText())=="")
    {
     $InnerText = GetSysTemplets("list_fulllist.htm");
    }
    else
    {
     $InnerText = trim($ctag->GetInnerText());
    }
    $this->dtp->Assign($tagid,
    $this->GetSqlList(
    $limitstart,
    $row,
    $ctag->GetAtt("sql"),
    $InnerText
    )
    );
   }
   //end

最后找到function GetArcList這個(gè)方法,在其后添加一個(gè)可以通過(guò)傳入sql參數(shù)獲取指定數(shù)據(jù)源的方法,代碼如下:


 function GetSqlList($limitstart = 0, $row = 10, $sql = '', $innertext){
 
  global $cfg_list_son;
  $innertext = trim($innertext);
 
  if ($innertext == '') {
   $innertext = GetSysTemplets('list_fulllist.htm');
  }
  //處理SQL語(yǔ)句
  $limitStr = " LIMIT {$limitstart},{$row}";
 
  $this->dsql->SetQuery($sql . $limitStr);
  $this->dsql->Execute('al');
  $t2 = ExecTime();
 
  //echo $t2-$t1;
  $sqllist = '';
  $this->dtp2->LoadSource($innertext);
  $GLOBALS['autoindex'] = 0;
 
  //獲取字段
  while($row = $this->dsql->GetArray("al")) {
 
   $GLOBALS['autoindex']++;
 
   if(is_array($this->dtp2->CTags))
   {
    foreach($this->dtp2->CTags as $k=>$ctag)
    {
     if($ctag->GetName()=='array')
     {
      //傳遞整個(gè)數(shù)組,在runphp模式中有特殊作用
      $this->dtp2->Assign($k,$row);
     }
     else
     {
      if(isset($row[$ctag->GetName()]))
      {
       $this->dtp2->Assign($k,$row[$ctag->GetName()]);
      }
      else
      {
       $this->dtp2->Assign($k,'');
      }
     }
    }
   }
 
   $sqllist .= $this->dtp2->GetResult();
 
  }//while
 
  $t3 = ExecTime();
  //echo ($t3-$t2);
  $this->dsql->FreeResult('al');
 
  return $sqllist;
 }
 //end

 

0532-85810878 473587358 掃碼添加微信

掃碼添加微信

掃碼關(guān)注公眾號(hào)

官方公眾號(hào)

2054585360
依安县| 台中县| 温州市| 上虞市| 洞头县| 临沭县| 张家川| 永平县| 泌阳县| 菏泽市| 南城县| 屯留县| 饶阳县| 河源市| 绥宁县| 永平县| 蓝山县| 柘城县| 乾安县| 台南市| 菏泽市| 乌鲁木齐县| 留坝县| 汤原县| 大埔县| 交口县| 木里| 禹州市| 白玉县| 寻甸| 奎屯市| 潢川县| 萨迦县| 武鸣县| 易门县| 定西市| 凤台县| 绩溪县| 卫辉市| 萍乡市| 凤台县|