I added two lines (below) to the MySQL query that broke the code. I can't figure out what needs to be changed. I've checked all relevant files. The error I get is: "No data available in table" as a response in a DataTable. Without those two lines, it works perfectly.
Line A
lp.image AS Picture,
Line B
JOIN LetterIT lp ON lp.letterid = lst.letterid
Below you can see the Model, View, and Controller with the added lines.
Model (Relevant Snippet)
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();
}
View (Relevant Snippet)
<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>
Controller (Relevant Snippet)
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));
}
If I am missing anything, please let me know :)