Thinkphp3.1 php 链接SqlServer

ThinkPHP链接

M("lk_employeeInfo","Null/表前缀","sqlsrv://账号:密码@服务器:端口/数据库")->query("select * from lk_employeeinfo where state = 'onJob'");

 PHP链接

try{  
    $db = sqlsrv_connect('服务器',array("UID"=>'账号', "PWD"=>'密码', "Database"=>"数据库"));
}catch(PDOException $e){  
    echo "ERROR:".$e->getMessage();  
}
$a = sqlsrv_query($db,"select * from lk_employeeinfo where state = 'onJob'");
while( $row = sqlsrv_fetch_array( $a, SQLSRV_FETCH_ASSOC) ) {
      echo $rew['roleid'];
}

 

转载于:https://www.cnblogs.com/wangzhaobo/p/8808633.html

你可能感兴趣的:(Thinkphp3.1 php 链接SqlServer)