PHP连接SQL Server
使用过SQL Server的人应该都清楚,SQL Server常用的有两种认证方式,一种是本地系统账户认证(Windows Authentication ),一种是使用用户名和密码(SQL Server Authentication ),第二种认证方式必须启用SQL Server的混合模式。
1.Windows Authentication连接部分代码段:
<?php
$serverName = "(local)";
$connectionInfo = array("Database"=>"TestingInfo","ConnectionPooling"=>false);
$conn = sqlsrv_connect( $serverName,$connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}
?>
2.SQL Server Authentication连接部分代码段:
<?php
$serverName = "(local)";
$uid = "sa";
$pwd = "******";
$connectionInfo = array("UID"=>$uid,"PWD"=>$pwd,"Database"=>"TestingInfo");
$conn = sqlsrv_connect( $serverName,$connectionInfo);
if( $conn == false)
{
echo "连接失败!";
die( print_r( sqlsrv_errors(), true));
}
?>
参考官方提供的英文原文档,针对参数$connectionInfo做一个简单说明,因为$connectionInfo是一个Hash表结构,下边参数格式为:
Key[DataType]:
Description(Default Value):键[数据类型]:描述(默认值)
【1】APP[String类型]:
使用的应用程序名称【*:我自己不太懂得这个地方的意义,不好意思】(没有默认值)
【2】ConnectionPooling[1或true为打开连接池,0或false为关闭连接池]:
用来设置是否打开SQL Server的连接池功能(默认值为true(1))
【3】Database[String类型]:
连接的数据库的名称,所有连接提供的数据库名称类似ASP.NET里面web.config的连接字符串里面的数据库实例名,如果设置了Database的连接属性,驱动会默认使用SQL Server支持的Transact-SQL脚本来操作所有提供的数据库实例,包括添加、删除、查询、修改等各种操作(默认为登陆的操作系统里面的数据库,我没有测试过,应该是直接运行程序的(local))
【4】Encrypt[1或true为执行加密,0或false为不执行加密]:
设置是否对传入服务器的SQL脚本执行加密操作,当然如果使用加密操作会对系统性能存在一定影响,不过影响不明显(默认为false(0))
【5】Failover_Partner[String类型]:
提供一个服务器镜像,此属性应该是用于主服务器Down掉的情况
相关文档:
<?php
class main extends spController
{
function index(){
echo "<p align=center><h1>HIS基础数据维护</h1>";
echo "<p align=center><h2>科室字典</h2>";
$contentsurl=spUrl("main", "i ......
只能是window下.
从php 官网上下载 php_gd2.dll (5.2.2版的.)
替换你原来的gd2.
自动抓取网站页面并保存为一个图片.
实现代码如下:
<?php
$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->FullScreen = true;
$browser->Nav ......
html部分
<Td><?php echo $row['bigclassid']?></Td>
<td height="25" width="241" class="bigclassname"><?php echo $row['bigclassname']?></a></td>
Js部分
<script>
/**//*
* 说明:用Jquery的方法,无刷新页面,编辑表格
*/
$(function() {
//给页 ......
function htmldecode($str)
{
if(empty($str)) return;
if($str=="") return $str;
$str=str_replace("&",chr(34),$str);
$str=str_replace(">",">",$str);
$str=str_replace("<","<",$str);
$str=str_replace("&","&",$str);
$str=str_replace(" ",chr(32),$str);
$str=str_replace(" ", ......
<?php
$start=$_GET['s'];
$end=$_GET['e'];
$requests = array();
for ($index = $start; $index < $end; $index++) {
$url="http://www.essort.com/amfphp/services/curl/loadTest.php?uid=$index";
$requests[]=$url;
}
$main = curl_multi_init();
$results = array();
$errors = array(); ......