Redbeanphp 命令错误
Redbeanphp bad order
使用这段代码,我解析了 table
中的 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>';
}
}
但最终没有找到最后的 post,一切都按升序排列。请帮帮我。我也试过了日期
$all = R::getAll( 'SELECT * FROM postdate ORDER BY date DESC LIMIT 125' );
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>';
}
}
使用这段代码,我解析了 table
中的 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>';
}
}
但最终没有找到最后的 post,一切都按升序排列。请帮帮我。我也试过了日期
$all = R::getAll( 'SELECT * FROM postdate ORDER BY date DESC LIMIT 125' );
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>';
}
}