我在破坏代码的MySQL查询中添加了两行(下面)。我无法弄清楚需要改变什么。我检查了所有相关文件。我得到的错误是:“表格中没有数据”作为DataTable中的响应。如果没有这两行,它就能完美运行。
A行
lp.image AS Picture,
B行
JOIN LetterIT lp ON lp.letterid = lst.letterid
下面您可以看到带有添加行的模型,视图和控制器。
模型(相关代码段)
public function get_letter_feed($user_id) {
$sql = "
SELECT
l.uuid AS Uuid,
ls.`statcode` AS StatusCode,
ls.`statname` AS StatusDescription,
lst.shortnotes AS Notes,
lp.image AS Picture,
CONCAT(LEFT(l.messages, 65), '') AS MessageBody,
l.rcpnt AS Recipient,
lst.createdtime AS Created
FROM Letters l
JOIN LetterAT lst ON lst.letterid = l.id AND lst.deleted IS NULL
JOIN LetterST ls ON ls.id=lst.statusId
JOIN LetterIT lp ON lp.letterid = lst.letterid
WHERE
l.ownerId = {$this->db->escape($user_id)}
ORDER BY lst.created DESC
LIMIT 10;";
return $this->db->query($sql)->result();
}
查看(相关代码段)
<table id="tableDataset">
<thead>
<tr>
<th>Recipient</th>
<th>Message Body</th>
<th>Date</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?foreach($letter_feed as $feed_item): ?>
<tr>
<td><?=$feed_item->Recipient?> </td>
<td><?=$feed_item->MessageBody?> </td>
<td><?=$feed_item->Created?> </td>
<td><?=$feed_item->StatusDescription?> <a href="<?=$feed_item->Picture?>" data-lightbox="photo"><b>(PHOTO)</b></a> </td>
</tr>
<?endforeach?>
</tbody>
控制器(相关代码段)
public function get_letter_status_feed_html() {
$letter_feed = $this->Letter_model->get_letter_feed($this->user->userId);
$this->load->view('dashboard/snippet/letter_status_feed', array('letter_feed'=>$letter_feed));
}
如果我遗失了什么,请告诉我:)