dongmaopiao0901 2018-07-10 12:37
浏览 60

查询在SqlServer上工作但不在PHP上(超过4000个字符的文本字段)

I am working on an existing PHP code using an undocumented external homemade framework. The database used is Sql Server 2008.

The program gets an Excel file, parses it and saves the data into the database using PDO. I have no access to the server config, only the code. I can't change the database configuration (the text type can't turn into a VARCHAR type).

One of the values was stopping the execution,

  • The error occurs just on the execute() command,
  • I replaced the content by a same lenght "Lorem ipsum" (assuming an encoding error or anything else), still not working,
  • I reduced the content lenght, it worked,
  • I checked into the database to get the data type, it is a TEXT field,
  • I played it again and again to know exactly the limit, this limit is 4000 characters,

I tried to execute the query on Sql Server (sample):

INSERT INTO [dbo].[database] (tableName, tableId, verifString, inErrorText, code, status) 
VALUES ('DIAG', 123455, 'diag', '[Long string more than 5000 characters]', 'ABC023','anoma')

It worked

I tried the exactly same query [only changing the id] in PHP (sample):

$statement =$this->db->prepare("INSERT INTO [dbo].[database] (tableName, tableId, verifString, inErrorText, code, status) 
VALUES ('DIAG', 123456, 'diag', '[Long string greater than 4000 characters]', 'ABC023','anoma')");
$statement->execute();

And again, the execution was stopped.

If I put a short string into the same query [only changing the id] (sample):

$statement =$this->db->prepare("INSERT INTO [dbo].[database] (tableName, tableId, verifString, inErrorText, code, status) 
VALUES ('DIAG', 123457, 'diag', '[Short string lower than 4000 characters]', 'ABC023','anoma')");
$statement->execute();

It works

I searched if there were any restrictions in the homemade framework but I didn't find anything.

Any idea?

I hope my english is understandable. Thanks for your attention.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c