猿问

Redbeanphp 错误命令

使用此代码,我解析表中的 post 元素


$all = R::findAll('postdate'," ORDER BY id DESC LIMIT 15");

    for($i = 1; $i <= count($all); $i++){

        if(isset($all[$i])){

            $date = date_create($all[$i]->date);

            $post = R::findOne('post', 'date_id = ?', array($all[$i]->id));

            $author = R::findOne('postauthor', 'id = ?', array($post->author_id));

            $title = R::findOne('posttitle', 'id = ?', array($post->title_id));

            echo '<div class=post>

                      <i class=post-date>'.date_format($date, 'd.m.Y G:i').' 📝 '.$author->author.'</i>

                      <h1>'.$title->title.'</h1><hr><br>'.

                      $post->content.

                  '</div>';

        }

        

    }

但最终没有找到最后的帖子,一切都按升序排列。请帮帮我。我也尝试过通过日期


心有法竹
浏览 73回答 1
1回答

紫衣仙女

$all = R::getAll( 'SELECT * FROM postdate ORDER BY date DESC LIMIT 125' );&nbsp; &nbsp; &nbsp; &nbsp; for($i = -1; $i <= count($all); $i++){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(isset($all[$i])){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $date = date_create($all[$i]['date']);&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $post = R::findOne('post', 'date_id = ?', array($all[$i]['id']));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $author = R::findOne('postauthor', 'id = ?', array($post->author_id));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $title = R::findOne('posttitle', 'id = ?', array($post->title_id));&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo '<div class=post>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <i class=post-date>'.date_format($date, 'd.m.Y G:i').' 📝 '.$author->author.'</i>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <h1>'.$title->title.'</h1><hr><br>'.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $post->content.&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '</div>';&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; }
随时随地看视频慕课网APP
我要回答