崇高片段:pageit
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了崇高片段:pageit相关的知识,希望对你有一定的参考价值。
This is a quick sublime snippet to quickly setup a DB table for pagination. Ideally from here you will be into a smarty template.
<snippet> <content><![CDATA[ $offset = 0; $page = 1; $pp = 6; $table = "users"; $field = "user_created_timestamp"; $dir = "DESC"; $offset = ( $page - 1 ) * $pp; } // get the total $q = "SELECT COUNT( * ) AS total FROM $table"; $qr = dbQuery( $q ); $qrow = dbFetchArray( $qr ); $total = $qrow['total']; // Do the real select $q = "SELECT * FROM ".$table." ORDER BY ".$field." ".$dir." LIMIT ".$pp." OFFSET ".$offset; $qr = dbQuery( $q ); $assigns['total'] = $total; $assigns['totalpages'] = $totalpages; $assigns['items'] = dbFetchAllArray( $qr ); $prev = false; $first = false; $next = true; $last = true; if( $offset != 0 ) { $prev = true; $first = true; } if( $page == $totalpages ) { $next = false; $last = false; } $assigns['prevpage'] = $page - 1; $assigns['nextpage'] = $page + 1; $assigns['first'] = $first; $assigns['prev'] = $prev; $assigns['next'] = $next; $assigns['last'] = $last; ]]></content> <tabTrigger>pageit</tabTrigger> <!-- Optional: Set a scope to limit where the snippet will trigger --> <!-- <scope>source.python</scope> --> </snippet>
以上是关于崇高片段:pageit的主要内容,如果未能解决你的问题,请参考以下文章