CodeIgniter - receive all messages except the last from the table

My scenario:

  • I want to publish all streams from a table in my database, except for the last one. I tried to use select_max, but it does not work. I cannot figure out what to add to the query string.

I just want to get all the messages and offset them by 1.

+3
source share
1 answer

Something like this might work:

SELECT * FROM table ORDER BY id DESC LIMIT 100,1 (limit 100, offset by 1)

or you get all the messages, and when you go through them in codeigniter you can do something like this:

$i = 1;
foreach($posts as $p):
    if($i != 1):
        //show posts
    endif;
$i++;
endforeach;
+1
source

Source: https://habr.com/ru/post/1783560/


All Articles