Hy!
I configured the modules/database/database.php file. In controller/index.php I have:
$query = DB::query(Database::SELECT, 'SELECT * FROM posts ORDER By id DESC');
Using phpmyadmin, I created two blog posts, but the script doesn't seem to get them from the database. I don't see any errors and also the blog posts are not visible.
P.S. Sorry for my bad English, I am a schoolboy f开发者_如何学运维rom Latvia and I'm learning English. :)
please read documentation: "Once you are done building, you can execute the query using execute() and use the results."
$query = DB::query(Database::SELECT, 'SELECT * FROM posts ORDER By id DESC')->execute();
Now you can use foreach.
foreach($query as $item){ .. }
I suggest to use Query Builder where it's possible to accidently avoid SQL injection in the future:
$query = DB::select()
->from('posts')
->order_by('id', 'DESC')
->execute();
精彩评论