douzen1896 2015-09-27 07:47
浏览 13

MySQL查询中的小变化,现在返回无数据?

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 :)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度