MS SQL Server 上的 ODBC 查询仅在 PHP PDO (FreeTDS) 中返回前 255 个字符

ODBC query on MS SQL Server returning first 255 characters only in PHP PDO (FreeTDS)(MS SQL Server 上的 ODBC 查询仅在 PHP PDO (FreeTDS) 中返回前 255 个字符)
本文介绍了MS SQL Server 上的 ODBC 查询仅在 PHP PDO (FreeTDS) 中返回前 255 个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我目前正在尝试从我们限制从 Linux Web 服务器访问的 SQL Server 数据库视图中提取一些数据.

I'm currently trying to pull some data from a SQL Server database view that we have restricted access to from our Linux web server.

我们不需要编辑数据,只需将其显示在网页中即可.

We don't need to edit the data just display it in a webpage.

一切看起来都很好,直到我们尝试输出并且只获取文本字段的前 255 个字符.

It all looks fine until we try to output and only get the first 255 characters of a text field.

有谁知道这是否是通过 PHP::PDO 使用 FreeTDS 的问题,或者它是否应该可以正常工作?我见过其他人也有类似的问题,但似乎没有多少答案.

Does anyone know if this is a problem with using FreeTDS through PHP::PDO or if it should work fine? I've seen other people out there having similar problems, but there don't seem to be many answers.

我将其用作 MS SQL 数据库的连接字符串:

I'm using this as the connection string for the MS SQL db:

$dbConn = new PDO("odbc:Driver=FreeTDS;DSN=OURDSN;UID=WWWUser;PWD=ourpassword");

推荐答案

根据 FreeTDS 用户指南,问题似乎是 FreeTDS 在与 SQL Server 交谈时只能处理 varchar 最多 255 个字符由于协议定义中固有的限制".任何比这更大的数据类型都需要text.

According to the FreeTDS User Guide, the issue seems to be that FreeTDS can only handle varchar up to 255 characters when talking to SQL Server "due to limitations inherent in the protocol definition". Anything bigger than that needs to be data type text.

您可以通过相应地修改架构或在查询期间转换数据类型来解决问题,如下所示:

You can resolve the issue either by modifying your schema accordingly, or converting the data type during your query, like this:

SELECT CAST(mycol as TEXT) FROM mytable

这篇关于MS SQL Server 上的 ODBC 查询仅在 PHP PDO (FreeTDS) 中返回前 255 个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)