【发布时间】:2012-12-29 14:15:08
【问题描述】:
我使用 php 和 pdo 和 pdo_dblib 来执行长选择查询(在这种情况下)。如果我直接在 sql 中运行此查询,我会收到结果,但如果我从 php 运行它,我会收到
207 General SQL Server error: Check messages from the SQL Server [207] (severity 16) [(null)]
我使用debugDumpParams 来查看准备后的查询是什么,但它只转储查询中的前 500 个字符,这可能就是问题所在。这是一些配置参数还是一个错误?
操作系统:Slackware PHP:5.4.7 pdo_dblib - 我自己编译 freetds - 来自http://slackbuilds.org/
Is there a maxium to the output of PDO::debugDumpParams?
编辑:
代码:
<?php
$dsn = 'dblib:host=XXXXXXXX;dbname=XXXXX';
$username='XXXXX';
$password='XXXXXXX';
$query = "select * from (
select Row_Number() over (order by
order_status.id desc) as RowIndex,
order_status.id as ID,
order_status.caller_type_id as CALLER_TYPE_ID,
order_status.phone as PHONE,
order_status.order_number as ORDER_NUMBER,
order_status.caller_client_data_id as CLIENT_DATA_ID,
order_status.caller_contact_phone_id as CALLER_CONTACT_PHONE_ID,
order_status.record_date as DATE,
order_status.call_date as CALL_DATE,
order_status.call_time as jueCALL_TIME,
order_status.username as USERNAME,
client_data.ID as CALLER_ID,
client_data.client_type_id as CLIENT_TYPE_ID,
client_data.name as NAME,
client_data.person as PERSON,
client_data.country_id as COUNTRY_ID,
client_data.city as CITY,
client_data.street as STREET,
client_data.street_number as STREET_NUMBER,
client_data.living_complex as LIVING_COMPLEX,
client_data.building as BUILDING,
client_data.entrance as ENTRANCE,
client_data.floor as FLOOR,
client_data.apartment as APARTMENT,
client_data.postal_code as POSTAL_CODE,
client_data.description as DESCRIPTION,
client_data.email as EMAIL,
country.name as COUNTRY,
client_type.type as CLIENT_TYPE,
caller_type.name as CALLER_TYPE,
contact_phone.phone as CALLER_CONTACT_PHONE
from order_status order_status
inner join client_data client_data on client_data.id = order_status.caller_client_data_id
inner join client_type client_type on client_type.id = client_data.client_type_id
inner join country country on country.id = client_data.country_id
inner join caller_type caller_type on caller_type.id = order_status.caller_type_id
inner join contact_phone on contact_phone.id = order_status.caller_contact_phone_id
where 1=1 ) as Sub Where Sub.RowIndex >= ? and Sub.RowIndex < ?";
$db = new PDO($dsn, $username, $password);
$prepare = $db->prepare($query, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$bind = array(1, 11);
if (!$prepare->execute($bind)) {
$prepare->debugDumpParams();
} else {
echo "success";
}
输出:
SQL: [1841] select * from (
select Row_Number() over (order by
order_status.id desc) as RowIndex,
order_status.id as ID,
order_status.caller_type_id as CALLER_TYPE_ID,
order_status.phone as PHONE,
order_status.order_number as ORDER_NUMBER,
order_status.caller_client_data_id as CLIENT_DATA_ID,
order_status.caller_contact_phone_id as CALLER_CONTACT_PHONE_ID,
order_status.record_date as DATE,
order_status.call_date as CALL_DATE,
order_status.call_time as jueCALL_T
Params: 2
Key: Position #0:
paramno=0
name=[0] ""
is_param=1
param_type=2
Key: Position #1:
paramno=1
name=[0] ""
is_param=1
param_type=2
【问题讨论】:
-
你是用
var_dump输出debugDumpParams吗? -
你能给我们看看代码吗?
-
在哪里使用 var_dump? debugDumpParams 直接输出...
-
根据 Google 的说法,当 SQL Server 尝试使用不存在的列名时会出现 207 错误。
-
如果我在 tsql 中运行这个查询,我会收到结果,所以问题不在于不存在的列。
标签: php sql-server pdo