1

我有一个 codeigniter 控制器,它从 API 接收 json 内容并将其插入到 mysql longtext 字段中。一切都顺利运行了一段时间,但最近我注意到一些内容被截断了。这里有两个例子。

插入的表有三个字段

id int 
data longtext 
date_added datetime

我正在接收数据并使用活动记录插入功能直接将其添加到数据库中。看起来像这样

$this->db->insert('received', array('data' => $data, 'date_added' => date('Y-m-d H:i:s')));

使用分析器,我监视了查询并发现了两个错误的:

INSERT INTO `received` (`data`, `date_added`) VALUES ('{\"status\":{\"lastMaintenanceAt\":0000,\"code\":304,\"period\":900},\"items\":[{\"permalinkUrl\":\"http://example.com\",\"updated\":0000,\"postedTime\":0000,\"summary\":\"Man\'s guarantees are like his words.\",\"title\":\"By: John\",\"content\":\"<p>Man&#8217;s guarantees are like his words.</p>\",\"id\":\"http://example.com\",\"actor\":{\"permalinkUrl\":\"\",\"displayName\":\"John\"}}],\"title\":\"Comments on: Banker refuses to give ‘Written Guarantee’\"}', '2012-04-08 00:28:29')

INSERT INTO `received` (`data`, `date_added`) VALUES ('{\"status\":{\"code\":304,\"period\":900,\"feed\":\"http://example.com\"},\"items\":[],\"title\":\"Comments on: Making her cry…\"}', '2012-04-08 00:49:35') 

查询似乎没问题。但在第一种情况下,只有部分 JSON 进入表格,它在 after"[...] refuses to give"和第二个 after 中被截断making her cry

查询未返回错误,并且日期已正确插入。此外,如果我复制查询并在 mysql 命令提示符下执行它们,它们将插入全文。这些查询是其他数百个成功查询中的一个。

知道可能是什么问题吗?

谢谢你

4

1 回答 1

2
于 2012-04-08T21:46:03.637 回答