我将 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/
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