prepare("select id,ztname,zttype,zttime,headimg,riseimg fro"/> prepare("select id,ztname,zttype,zttime,headimg,riseimg fro">
首页 > 后端开发 > php教程 > 怎么在function里操作pdo呀

怎么在function里操作pdo呀

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
发布: 2016-06-13 11:44:07
原创
936 人浏览过

如何在function里操作pdo呀
代码如下

require("../inc/pdo.php");<br /><br />function output($action,$select,$name){<br />$select=$dbc->prepare("select id,ztname,zttype,zttime,headimg,riseimg from naszt where 1=1 and zttype=:zttype");<br />$select->bindValue(":zttype",$action);<br />$select->execute();<br />$result='';<br />while($row=$select->fetch()){<br />$result.='<ul id="thumbs"><li class="'.$name.'">';<br />$result.='<div class="img-container">';<br />$result.='<div class="item-img">';<br />$result.='<img  src="ztImg/'.$row['riseimg'].'"   style="max-width:90%"怎么在function里操作pdo呀" ></div><ul>';<br />$result.='<li><a href="portfolio-single.html" class="view">测试1</a></li>';<br />$result.='<li><a href='.$row['headimg'].' class="preview" data-rel="prettyPhoto[web]">测试12</a></li></ul></div><div class="item-info">';<br />$result.='<h3 class="title">'.$row['ztname'].'</h3>';<br />$result.='<span class="category">'. $row['zttype'].'</span>';	<br />$result.='<p class="intro">1推荐日期:'.$row['zttime'].'</p></div></li>';<br />	}<br />return $result;<br />}
登录后复制


<?php<br />header("Content-Type:text/html;charset=utf-8");<br />$dbtype='mysql';<br />$host='127.0.0.1';<br />$dbName='nas';<br />$user='227227';<br />$pass='227227';<br />$db="$dbtype:host=$host;dbname=$dbName";<br />try{<br />$dbc=new PDO($db,$user,$pass);<br />$dbc->exec('SET CHARACTER SET utf8');<br />$dbc->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); //禁用prepared statements的仿真<br />	}catch(PDOException $e){<br />echo $e->getMessage();<br />}<br />?>
登录后复制


我想在function调用pdo
是不是在pdo里面写class function要继承这个类?

求大神出手指点该如何写!

相关标签:
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板