Home > Backend Development > PHP Tutorial > 版主 sqlsrv 自个儿弄的简单类还需要您的帮助

版主 sqlsrv 自个儿弄的简单类还需要您的帮助

WBOY
Release: 2016-06-13 12:14:18
Original
1088 people have browsed it

版主 sqlsrv 自己弄的简单类还需要您的帮助

<br />class DB_sqlsrv<br />{<br />    var $query;<br />	var $result;<br />	function DB_sqlsrv($text)<br />	{<br />		<br />				$serverName = "192.168.0.1";<br />				$connectionInfo = array(<br />				"UID"=>"sa",<br />				"PWD"=>"sa",<br />				"Database"=>"ttt"<br />				$conn = sqlsrv_connect( $serverName, $connectionInfo);<br />				$this->query=sqlsrv_query($conn, $text);<br />	}<br />	//以对象形式取得查询结果数据<br />	function Record()<br />	{<br />		$this->result=sqlsrv_fetch_object($this->query);<br />		return ($this->result)?($this->result):false;<br />	}<br />}<br />$sql=new DB_sqlsrv("select * from username");<br />$record=$sql->Record();<br />
Copy after login


出错  PHP Warning:  sqlsrv_fetch_object(): 2 is not a valid ss_sqlsrv_stmt resource in E:\web\test\test\test.php on line 20
$this->result=sqlsrv_fetch_object($this->query);
这句有问题,我看看类好像没有问题的。请教谢谢。
------解决思路----------------------
$this->query=sqlsrv_query($conn, $text);
执行失败

你 var_dump($this->query); 看看是什么

Related labels:
source:php.cn
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