gpt4 book ai didi

php - Zend_Db_Table Select missing data,直接PHP查询ok

转载 作者:行者123 更新时间:2023-11-29 03:43:26 25 4
gpt4 key购买 nike

我正在将 php 应用程序转换为 zend 框架并利用 Zend_Db_Table 进行查询。我的问题是,在转换为 zend 格式后,文本格式字段的预期结果返回一个空字符串而不是存储的数据。

文本字段长度为 11000 的记录始终返回空,而另一条长度为 2500 的记录始终正确返回。

我需要配置什么吗?使用 zend db table 返回的数据是否有限制?

PHP MySQL 使用 mysqli,返回 true,var 有值

$db = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$stmt= "select * from m_message where m.m_id='".$m_id."'";
$result = $db->query($q_message);

$result['m_content'] 等于“我得到了...的副本”(11000 个字符/长度)

Zend 使用pdo_mysql,返回true,var 没有值

$this->_db = Zend_Db_Table::getDefaultAdapter();
$stmt = $this->_db->query('SELECT m_content FROM m_message WHERE m_id = ? ', $messageId);
$result = $stmt->fetchAll();

$result['m_content'] 等于(字符串)

$this->_db = Zend_Db_Table::getDefaultAdapter(); 
$stmt = $this->_db->select()->from('m_message', 'm_content')->where('m_id = ?',$messageId );
$result = $this->_db->fetchAll($stmt);

$result['m_content'] 等于(字符串)

更新

事实证明,在 Netbeans 中调试时观察变量时它显示为 null。正如预期的那样,变量的 var_dump 实际上显示了数据。问题是当我使用 JSON 帮助程序将数组作为 json 返回时。在查看 json_last_error() 时,它返回了 5,JSON_ERROR_UTF8。

我的数据库字符集是 UTF-8,但是为了解决这个问题,我必须在将它传递给 json 助手之前执行 utf8_encode($result['m_content']) :/

最佳答案

对于你的上次更新,试试这个,所以你的连接实际上是 UTF-8。

$db = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
$this->_db->query("SET NAMES 'utf8'");

关于php - Zend_Db_Table Select missing data,直接PHP查询ok,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10183011/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com