doutenglou6588 2019-03-21 20:06 采纳率: 0%
浏览 39
已采纳

PHP中Microsoft SQL Server的连接参数

I'm trying to connect to Microsoft SQL Server with PHP

To work with a mirrored database in the sql management studio I use "ApplicationIntent=ReadOnly" in the "Additional Connection Parameters" label.

How can I set this parameter in php?

Example of how I'm connection without the parameter:

$serverName = "server, port";
$connectionInfo = array( "Database"=>"my_db");
$conn = sqlsrv_connect( $serverName, $connectionInfo);
  • 写回答

1条回答 默认 最新

  • dsjq6977 2019-03-21 20:59
    关注

    You can pass it as one of the options, like so:

    sqlsrv_connect($serverName, ['ApplicationIntent' => 'ReadOnly']);
    

    Or in your case:

    $serverName = "server, port"; 
    $connectionInfo = array('Database' => 'my_db', 'ApplicationIntent' => 'ReadOnly'); 
    $conn = sqlsrv_connect( $serverName, $connectionInfo);
    

    See also the php docs for sqlsrv_connect().

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求TYPCE母转母转接头24PIN线路板图
  • ¥100 国外网络搭建,有偿交流
  • ¥15 高价求中通快递查询接口
  • ¥15 解决一个加好友限制问题 或者有好的方案
  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型