PHP 5.6升级后SQLSRV无法获取数据(SQLSRV Not Getting Data after PHP 5.6 Upgrade)
我有一个问题,我似乎无法包裹自己,所以SO社区似乎是个好去处!
我有3个PHP服务,它们只是从同一个DB的不同表中返回数据并将其作为json吐出。 3个服务都使用相同的精确代码和不同的select语句。 问题是我能够获取两个服务的数据,但不能获得一个服务(具有最大的数据集)。 我已经将我的资源配置从PHP 5.4到5.6匹配,但仍然没有结果。 所有这三种服务在PHP 5.4上运行良好,但在5.6升级之后,只有一种不能(同样,SAME CODE)。
我正在附上以下两项服务,以便您可以进行比较。 我已经验证了我的SQL语句,并检查了所有日志文件。 PHP显示没有错误,IIS显示200(在两个服务上完成GET)。
失败的服务
include "config/db.php"; $detailsConn = sqlsrv_connect($serverName, $connectionInfo); if (!$detailsConn) { die('Connection failed!'); } do { $json = array(); $detailsSql = "SELECT * from dbo.DeviceTypeTable_Desktop LEFT JOIN dbo.IPAddresses ON dbo.DeviceTypeTable_Desktop.IPAddressId=dbo.IPAddresses.IPAddressid WHERE IsDeleted = 'false'"; $detailsStmt = sqlsrv_query($detailsConn, $detailsSql); while ($row = sqlsrv_fetch_array($detailsStmt, SQLSRV_FETCH_ASSOC)) { $json[] = $row; } $detailsSql = "SELECT * from dbo.DeviceTypeTable_Laptop LEFT JOIN dbo.IPAddresses ON dbo.DeviceTypeTable_Laptop.IPAddressId=dbo.IPAddresses.IPAddressid WHERE IsDeleted = 'false'"; $detailsStmt = sqlsrv_query($detailsConn, $detailsSql); while ($row = sqlsrv_fetch_array($detailsStmt, SQLSRV_FETCH_ASSOC)) { $json[] = $row; } } while (sqlsrv_next_result($detailsStmt)); echo json_encode($json); sqlsrv_free_stmt($detailsStmt); sqlsrv_close($detailsConn);
工作服务
include "config/db.php"; $detailsConn = sqlsrv_connect($serverName, $connectionInfo); if (!$detailsConn) { die('Connection failed!'); } do { $json = array(); $detailsSql = "SELECT * from dbo.DeviceTypeTable_Yuma LEFT JOIN dbo.IPAddresses ON dbo.DeviceTypeTable_Yuma.IPAddressId=dbo.IPAddresses.IPAddressid WHERE IsDeleted = 'false'"; $detailsStmt = sqlsrv_query($detailsConn, $detailsSql); while ($row = sqlsrv_fetch_array($detailsStmt, SQLSRV_FETCH_ASSOC)) { $json[] = $row; } $detailsSql = "SELECT * from dbo.DeviceTypeTable_iPad LEFT JOIN dbo.IPAddresses ON dbo.DeviceTypeTable_iPad.IPAddressId=dbo.IPAddresses.IPAddressid WHERE IsDeleted = 'false'"; $detailsStmt = sqlsrv_query($detailsConn, $detailsSql); while ($row = sqlsrv_fetch_array($detailsStmt, SQLSRV_FETCH_ASSOC)) { $json[] = $row; } } while (sqlsrv_next_result($detailsStmt)); echo json_encode($json); sqlsrv_free_stmt($detailsStmt); sqlsrv_close($detailsConn);
编辑:我已经在机器上重新安装了PHP 5.6,并确保我的SQLSRV驱动程序已正确安装(因为它适用于其他2个!)。
在完成所有这些之后我还重新启动了IIS来验证。
I've got a problem that I can't seem to wrap my self around so the SO community seemed like the place to go!
I've got 3 PHP services that very simply return data from different tables of the same DB and spit it out as json. The 3 services all use the same exact code with a different select statement. The issue is that I'm able to get my data on two of the services but not on one (which happens to have the largest data set). I've matched my Resource Configuration from PHP 5.4 to 5.6 and still no results. All three services work fine on PHP 5.4 but after the 5.6 upgrade, only one doesn't (again, SAME CODE).
I'm attaching both services below so that you can compare. I've verified my SQL statements, and checked all log files. PHP shows no errors and IIS shows a 200 (completed GET on both services).
FAILING SERVICE
include "config/db.php"; $detailsConn = sqlsrv_connect($serverName, $connectionInfo); if (!$detailsConn) { die('Connection failed!'); } do { $json = array(); $detailsSql = "SELECT * from dbo.DeviceTypeTable_Desktop LEFT JOIN dbo.IPAddresses ON dbo.DeviceTypeTable_Desktop.IPAddressId=dbo.IPAddresses.IPAddressid WHERE IsDeleted = 'false'"; $detailsStmt = sqlsrv_query($detailsConn, $detailsSql); while ($row = sqlsrv_fetch_array($detailsStmt, SQLSRV_FETCH_ASSOC)) { $json[] = $row; } $detailsSql = "SELECT * from dbo.DeviceTypeTable_Laptop LEFT JOIN dbo.IPAddresses ON dbo.DeviceTypeTable_Laptop.IPAddressId=dbo.IPAddresses.IPAddressid WHERE IsDeleted = 'false'"; $detailsStmt = sqlsrv_query($detailsConn, $detailsSql); while ($row = sqlsrv_fetch_array($detailsStmt, SQLSRV_FETCH_ASSOC)) { $json[] = $row; } } while (sqlsrv_next_result($detailsStmt)); echo json_encode($json); sqlsrv_free_stmt($detailsStmt); sqlsrv_close($detailsConn);
WORKING SERVICE
include "config/db.php"; $detailsConn = sqlsrv_connect($serverName, $connectionInfo); if (!$detailsConn) { die('Connection failed!'); } do { $json = array(); $detailsSql = "SELECT * from dbo.DeviceTypeTable_Yuma LEFT JOIN dbo.IPAddresses ON dbo.DeviceTypeTable_Yuma.IPAddressId=dbo.IPAddresses.IPAddressid WHERE IsDeleted = 'false'"; $detailsStmt = sqlsrv_query($detailsConn, $detailsSql); while ($row = sqlsrv_fetch_array($detailsStmt, SQLSRV_FETCH_ASSOC)) { $json[] = $row; } $detailsSql = "SELECT * from dbo.DeviceTypeTable_iPad LEFT JOIN dbo.IPAddresses ON dbo.DeviceTypeTable_iPad.IPAddressId=dbo.IPAddresses.IPAddressid WHERE IsDeleted = 'false'"; $detailsStmt = sqlsrv_query($detailsConn, $detailsSql); while ($row = sqlsrv_fetch_array($detailsStmt, SQLSRV_FETCH_ASSOC)) { $json[] = $row; } } while (sqlsrv_next_result($detailsStmt)); echo json_encode($json); sqlsrv_free_stmt($detailsStmt); sqlsrv_close($detailsConn);
EDIT: I've reinstalled PHP 5.6 on the machine and made sure that my SQLSRV driver was properly installed(as it works on 2 others!).
I've also restarted IIS after all this to verify.
原文:https://stackoverflow.com/questions/36043893
最满意答案
我已经选择了一种相当粗略但有效的技术:在我的开发环境中,我有一个名为'environment_development'的空文件。 在我的生产环境中,我有一个名为'environment_PRODUCTION'(增加视觉强调的不同情况)。 我的gitignore文件设置为忽略这两个。
我的应用程序的前端控制器(我使用Kohana框架,但我假设CakePHP有类似的东西)检查这些文件的存在并适当地设置IN_PRODUCTION常量。 其余代码(数据库配置,错误处理等)可以检查此常量的值并根据需要更改行为。
我以前使用$ _SERVER ['SERVER_NAME']检查,但此方法具有以下优点:
- 即使您希望从命令行运行应用程序的某些部分,例如,作为cronjobs,当未设置$ _SERVER时,它也能正常工作。
- 即使您的应用在多个域上运行,它仍然有效。
- 它是完全明确的:如果有人检查了应用程序的另一个工作副本,那么在创建环境文件之前什么都不会起作用,因此没有(或很少)机会有人对生产数据库运行开发代码,反之亦然。
I've gone for a rather crude but effective technique: In my development environment I have an empty file called 'environment_development'. In my production environment I have one called 'environment_PRODUCTION' (different case for added visual emphasis). My gitignore file is set to ignore both of these.
The front controller of my application (I use the Kohana framework, but I'm presuming CakePHP has something similar) checks for the presence of these files and sets an IN_PRODUCTION constant appropriately. The rest of the code (database configuration, error handling etc.) can check the value of this constant and alter behaviour as required.
I used to use the $_SERVER['SERVER_NAME'] check, but this method has the following advantages:
- It works even if there are parts of your app you want to run from the command line, e.g., as cronjobs, when $_SERVER is not set.
- It works even if your app runs on multiple domains.
- It is entirely explicit: if someone checks out another working copy of the app, nothing will function until they create an environment file, so there's no (or very little) chance of someone running development code against the production db or vice versa.
相关问答
更多-
使用git在测试和生产环境之间同步数据库(Synchronizing databases between testing and production environment with git)[2022-09-03]
如果您想版本控制在平面文件中实现的完整数据库,我建议使用sqlite后端。 如果您的应用程序需要MySQL(例如某些过程或视图),则版本控制数据库操作脚本(例如CREATE , ALTER )和填充脚本(例如INSERT )并在构建过程中运行它们。 dbdeploy是一个很好的模式 。 更新您对现有程序的评论 您实际上将生产视为架构的主副本。 如果你有多个主人会怎么样? 当您的数据库太大而无法有效执行此操作时会发生什么? 如果您需要隔离旧版本代码中的错误怎么办?回滚到特定代码/架构状态有多容易? 十年前,我 ... -
我终于找到了这个问题! 在使用DependencyWalker分析NSASS的dll之后,我发现服务器没有正确版本的C ++ Redistriburable。 所以安装后一切正常! 希望这可以帮助其他人解决同样的问题。 I finally found the issue! After using DependencyWalker to analyze the dlls of NSASS I found that the server did not have the correct version of C ...
-
生产环境变量(Environment variables on production)[2023-02-18]
你可以使用figaro宝石。 我正在使用它,它在生产中工作正常。 You could use the figaro gem. I am using this and it works fine in production. -
设置暂存环境(Setting up a staging environment)[2024-03-10]
一个暂存环境,它基本上是另一个空间(通常是服务器,但如果你使用共享主机,然后是另一个帐户),这与你的生产空间完全相同,所以你可以测试好像你在真实的服务器上,而不会破坏你的生活现场。 任何东西都可以是一个临时环境,但除非它是一个相同的空间,否则测试没有意义。 A staging environment it basically a another space (usually a server, but if you're using shared hosting then another account) ... -
如何处理直接在生产环境中工作的其他团队?(How to deal with other teams working directly in the production environment?)[2021-12-13]
如果你真的不能让他们使用版本控制系统,我能想到的唯一解决方案是编写一个脚本(在生产环境中运行),它将定期提交和推送他们的代码。 至少,您可以为团队提取它,以便在推送自己的代码之前合并它。 那不干净。 完全没有。 但你似乎非常绝望,我想你不能只是摆脱他们。 If you really can't make them use a version control system, the only solution I can think of is to write a script (running on th ... -
单击https://www.parse.com/apps上的设置图标时,我会看到克隆选项。 这是你想要的? I see a clone option when clicking on the settings icon on https://www.parse.com/apps. Is this what you are looking for?
-
测试appcelerator arrowdb生产环境,我该怎么做?(Testing appcelerator arrowdb production environment, how do I do this?)[2021-12-31]
您的tiapp.xml应该类似于:123 https://secure-identity.cloud.appcelerator.com https: ... -
我已经选择了一种相当粗略但有效的技术:在我的开发环境中,我有一个名为'environment_development'的空文件。 在我的生产环境中,我有一个名为'environment_PRODUCTION'(增加视觉强调的不同情况)。 我的gitignore文件设置为忽略这两个。 我的应用程序的前端控制器(我使用Kohana框架,但我假设CakePHP有类似的东西)检查这些文件的存在并适当地设置IN_PRODUCTION常量。 其余代码(数据库配置,错误处理等)可以检查此常量的值并根据需要更改行为。 我以 ...
-
Pentaho CE堆栈从测试到生产环境的部署(Pentaho CE stack deployment from test to production environment)[2022-02-23]
下载/上传是通常的程序。 您还可以查看市场中的Repository Synchronizer。 这可能有助于简化部分工作。 Download/Upload is the usual procedure. You can also take a look at the Repository Synchronizer in the marketplace. That might be helpful to ease part of the work. -
在web.config文件中的appSettings下,我使用此键: