性能:PHP 和 MS SQL Server:使用 Exec 或 Driver 的 SQLCMD

发布于 2024-08-07 16:50:08 字数 550 浏览 3 评论 0原文

我目前正在使用 SQLCMD 对 SQL Server 进行查询,并从 PHP 的 exec() 函数运行它。我希望澄清这并不像 PHP 的 SQL Server 驱动程序那么有效: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx。我不确定这是否与 https://www.php 相同。 net/manual/en/book.mssql.php

我发现每次运行 exec 命令时,响应速度都相当慢,我希望在转向这个新驱动程序并实现它之前得到确认。使用此驱动程序而不是使用 exec 函数来启动 SQLCMD 是否存在性能差异?

我知道这有点模糊,但我真的很感谢您对这个决定的帮助。

谢谢大家

I am currrently making queries to my SQL Server using SQLCMD and I run this from PHPs exec() function. I was hoping to clarify that this isn't as efficient as the driver for SQL Server for PHP: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx. I am not sure if this is the same as https://www.php.net/manual/en/book.mssql.php?

I find that everytime I run an exec command it is quite a slow response and I was hoping to get this confirmed before I move to this new driver and implement it. Is there a performance difference using this Driver rather than using the exec function to launch SQLCMD?

I know this is a bit fluffy, but I really appreciate help on this decision.

Thanks all

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

君勿笑 2024-08-14 16:50:08

呃,是的,摆脱你的 exec 并使用 php 客户端库。您也不必处理从命令行解析结果集的问题。

Ugg, yeah, get rid of your exec and use the php client library. You also won't have to deal with parsing your result sets back off the command line.

巡山小妖精 2024-08-14 16:50:08

使用 exec 或其他程序执行函数之一启动另一个命令,需要时间 ;使用一些 PHP 函数/类可能总是更快 - 更容易:

  • 无需启动另一个命令,
  • 参数传递没有问题,
  • 无需解析输出:您将获得本机 PHP 数据作为输出,
  • 减少诸如“找不到命令”之类的问题,或者 UNIX/Linux 和 Windows 之间的差异,
  • 安全模式等没有问题,

我肯定会使用 PHP 扩展提供的某些函数,而不是使用 exec。

作为旁注,在这种特定情况下:

  • PHP 的 SQL Server 驱动程序当前仅在 Windows 平台上可用 - Linux 上不存在:-(
  • 它不能作为 PDO 驱动程序使用:您必须使用特定的 sqlsrv_* 函数

Launching another command, using exec or one of the other Program execution Functions, takes time ; using some PHP function/classes will probably always be faster -- and easier :

  • no need to launch another command
  • no problem for parameters passing
  • no parsing of the output : you'll get native PHP data as output
  • less problems like "command not found", or differences between UNIX/Linux and Windows
  • no problem with safe_mode and the like

I would definitly go with using some function provided by a PHP extension, instead of using exec.

As a sidenote, in this specific case :

  • the SQL Server driver for PHP is currently only available on Windows platforms -- doesn't exist for Linux :-(
  • it's not available as a PDO driver : you have to use the specific sqlsrv_* functions
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文