本文实例讲述了cakephp打印sql语句的方法。分享给大家供大家参考。具体实现方法如下:

代码很简单,就不多废话了。

本文实例讲述了php生成RSS订阅的方法。分享给大家供大家参考。具体分析如下:

将以下语句复制到你的代码中,可以打印出在这之前所有的sql语句:

复制代码
代码如下:$array=array(“1″,”2″,”3″,”4″,”5″,”6″,”7″,”8″,”9″,”10″,”11″,”12″,”13″,”14″,”15″,”16″,”17″,”18″,”19″,”20”);//规定要分页的数组$page=
$_GET[‘page’];$r = $this->page;print_r;foreach{echo $s;}function
page($array,$pagesize,$current){$_return=array();$total=ceil/$pagesize);//求总页数$prev=<=0
? “1”:;//确定上一页,如果当前页是第一页,点击显示第一页$next=>=$total
?
$total:$current+1);//确定下一页,如果当前页是最后一页,点击下页显示最后一页$current=?;//当前页如果大于总页数,当前页为最后一页$start=*$pagesize;//分页显示时,应该从多少条信息开始读取for($i=$start;$ifirst
prev
next
end”;//分页样式可跟据需要调整return
$pagearray;}

RSS是一种描述和同步网站内容的格式。RSS可以是以下三个解释的其中一个:
Really Simple Syndication;RDF (Resource Description Framework) Site
Summary; Rich Site
Summary。但其实这三个解释都是指同一种Syndication的技术。RSS目前广泛用于网上新闻频道,blog和wiki。使用RSS订阅能更快地获取信息,网站提供RSS输出,有利于让用户获取网站内容的最新更新。网络用户可以在客户端借助于支持RSS的聚合工具软件,在不打开网站内容页面的情况下阅读支持RSS输出的网站内容。从技术上来说一个RSS文件就是一段规范的XML数据,该文件一般以rss,xml或者rdf作为后缀,下面是一段
rss 文件的内容示例:复制代码 代码如下:

$sources = ConnectionManager::sourceList: $logs = array(); foreach : $db =& ConnectionManager::getDataSource; if (!$db->isInterfaceSupported: continue; endif; $logs[$source] = $db->getLog(); endforeach; endif;

以上就是使用array函数实现分页的核心代码了,希望大家能够喜欢。

脚本之家

希望本文所述对大家基于cakePHP框架的php程序设计有所帮助。

//www.jb51.net/ 脚本之家

RSS Tutorial

网站地址/rss New RSS tutorial on W3School

XML Tutorial

网站地址/xml New XML tutorial on W3School

下面分享一段使用 php 动态生成 RSS 的代码示例:复制代码
代码如下:syndicateHtml=$this->descriptionHtmlSyndicated;
$descriptionField->truncSize=$this->descriptionTruncSize; return
$descriptionField->output(); } } class FeedHtmlField{ var
$rawFieldContent; var $truncSize,$syndicateHtml; function FeedHtmlField{
if{ $this->rawFieldContent=$parFieldContent; } } function output(){
if(!$this->rawFieldContent){ $result=””; } elseif{
$result=”rawFieldContent.”]]>”; }else{ if($this->truncSize and
is_int{
$result=FeedCreator::iTrunc(htmlspecialchars($this->rawFieldContent),$this->truncSize);
}else{ $result=htmlspecialchars($this->rawFieldContent); } } return
$result; } } class UniversalFeedCreator extends FeedCreator{ var
$_feed; function _setFormat{ switch { case “2.0”: // fall through case
“RSS2.0”: $this->_feed=new RSSCreator20(); break; case “0.91”: //
fall through case “RSS0.91”: $this->_feed=new RSSCreator091();
break; default: $this->_feed=new RSSCreator091(); break; }
$vars=get_object_vars; foreach ($vars as $key => $value){ //
prevent overwriting of properties “contentType”,”encoding”; do not copy
“_feed” itself if(!in_array($key,
array(“_feed”,”contentType”,”encoding”))){
$this->_feed->{$key}=$this->{$key}; } } } function createFeed{
$this->_setFormat; return $this->_feed->createFeed(); }
function saveFeed($format=”RSS0.91″,$filename=””,$displayContents=true){
$this->_setFormat;
$this->_feed->saveFeed($filename,$displayContents); } function
useCached($format=”RSS0.91″,$filename=””,$timeout=3600){
$this->_setFormat; $this->_feed->useCached; } } class
FeedCreator extends HtmlDescribable{ var $title,$description,$link; var
$syndicationURL,$image,$language,$copyright,$pubDate,$lastBuildDate,$editor,$editorEmail,$webmaster,$category,$docs,$ttl,$rating,$skipHours,$skipDays;
var $xslStyleSheet=””; var $items=Array(); var
$contentType=”application/xml”; var $encoding=”utf-8″; var
$additionalElements=Array(); function addItem{
$this->items[]=$item; } function clearItem2Null(){
$this->items=array(); } function iTrunc{ if<=$length){ return
$string; } $pos=strrpos; if{ $string=substr; $pos=strrpos; } if{ return
substr.” …”; } $pos=strrpos; if{ $string=substr; $pos=strrpos; } if{
return substr.” …”; } return substr.” …”; } function
_createGeneratorComment(){ return “\n”; } function
_createAdditionalElements($elements,$indentString=””){ $ae=””; if{
foreach($elements AS $key => $value){ $ae.=
$indentString.”$value$key>\n”; } } return $ae; } function
_createStylesheetReferences(){ $xml=””; if $xml .= “cssStyleSheet.”\”
type=\”text/css\”?>\n”; if $xml .= “xslStyleSheet.”\”
type=\”text/xsl\”?>\n”; return $xml; } function createFeed(){}
function _generateFilename(){ $fileInfo=pathinfo; return
substr($fileInfo[“basename”],0,-(strlen($fileInfo[“extension”])+1)).”.xml”;
} function _redirect{ Header(“Content-Type: “.$this->contentType.”;
charset=”.$this->encoding.”; filename=”.basename;
Header(“Content-Disposition: inline; filename=”.basename; readfile; }
function useCached($filename=””,$timeout=3600){
$this->_timeout=$timeout; if{
$filename=$this->_generateFilename(); } if(file_exists-filemtime
< $timeout)){ $this->_redirect; } } function
saveFeed($filename=””,$displayContents=true){ if{
$filename=$this->_generateFilename(); } $feedFile=fopen; if{
fputs($feedFile,$this->createFeed; if{ $this->_redirect; } }else{
echo “
Error creating feed file, please check write permissions.
“; } } } class FeedDate{ var $unix; function FeedDate{ if
$dateString=date; if(is_integer{ $this->unix=$dateString; return; }
if(preg_match(“~(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),\\s+)?\\s+\\s+:\\s+~”,$dateString,$matches)){
$months=Array(“Jan”=>1,”Feb”=>2,”Mar”=>3,”Apr”=>4,”May”=>5,”Jun”=>6,”Jul”=>7,”Aug”=>8,”Sep”=>9,”Oct”=>10,”Nov”=>11,”Dec”=>12);
$this->unix=mktime($matches[4],$matches[5],$matches[6],$months[$matches[2]],$matches[1],$matches[3]);
if(substr==’+’ OR substr==’-‘){ $tzOffset=(substr * 60 + substr * 60;
}else{ if==1){ $oneHour=3600; $ord=ord; if{ $tzOffset= * $oneHour; }
elseif && $matches[7]!=”Z”){ $tzOffset= * $oneHour; } elseif{
$tzOffset=0; } } switch { case “UT”: case “GMT”: $tzOffset=0; } }
$this->unix += $tzOffset; return; } if-T:~”,$dateString,$matches)){
$this->unix=mktime($matches[4],$matches[5],$matches[6],$matches[2],$matches[3],$matches[1]);
if(substr==’+’ OR substr==’-‘){ $tzOffset=(substr * 60 + substr * 60;
}else{ if{ $tzOffset=0; } } $this->unix += $tzOffset; return; }
$this->unix=0; } function rfc822(){ $date=gmdate(“Y-m-d
H:i:s”,$this->unix); if $date .= ” “.str_replace; return $date; }
function iso8601(){ $date=gmdate(“Y-m-d H:i:s”,$this->unix);
$date=substr . ‘:’ . substr; if
$date=str_replace(“+00:00″,TIME_ZONE,$date); return $date; } function
unix(){ return $this->unix; } } class RSSCreator10 extends
FeedCreator{ function createFeed(){ $feed=”encoding.”\”?>\n”;
$feed.= $this->_createGeneratorComment();
if($this->cssStyleSheet==””){
$cssStyleSheet=””; } $feed.=
$this->_createStylesheetReferences(); $feed.= “\n”; $feed.= ”
syndicationURL.”\”>\n”; $feed.= “

发表评论

电子邮件地址不会被公开。 必填项已用*标注