prepare("select id,ztname,zttype,zttime,headimg,riseimg "/> prepare("select id,ztname,zttype,zttime,headimg,riseimg ">
Home > Backend Development > PHP Tutorial > 怎么在function里操作pdo呀

怎么在function里操作pdo呀

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:30:19
Original
942 people have browsed it

如何在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 />
}
Copy after login


<?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 />
?>
Copy after login


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

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

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template