当前位置:Gxlcms > PHP教程 > 版主sqlsrv自个儿弄的简单类还需要您的帮助

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

时间:2021-07-01 10:21:17 帮助过:15人阅读

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

class DB_sqlsrv
{
var $query;
var $result;
function DB_sqlsrv($text)
{

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


出错 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); 看看是什么

人气教程排行