日本語:Dbal.sql query limit

dbal::sql_query_limit -- SQL クエリに LIMIT を付けて送信する.

説明
resource dbal::sql_query_limit ( string $query, int $total [, int $offset [, int $cache_ttl ]] )

例 #1
$post_id = 25;

// Start on row 10 $start = 10;

// Select 5 rows (limit/offset) $limit = 5;

$sql = 'SELECT * FROM '. POSTS_TABLE. '   WHERE post_id = '. (int) $post_id; $result = $db->sql_query_limit($sql, $limit, $start);

例 #2
$start = request_var('start', 0);

$sql = 'SELECT post_text FROM '. POSTS_TABLE. '   WHERE forum_id = '. (int) $forum_id; // return 100 rows $result = $db->sql_query_limit($sql, 100, $start);

例 #3
$sql_array = array(   'SELECT' => 'f.*, ft.mark_time',    'FROM' => array( FORUMS_WATCH_TABLE => 'fw', FORUMS_TABLE => 'f'   ),    'LEFT_JOIN' => array( array(           'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),            'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'        ) ),   'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '        AND f.forum_id = fw.forum_id',    'ORDER_BY' => 'left_id' );

$sql = $db->sql_build_query('SELECT', $sql_array);

// now run the query returning only the first 10 results $result = $db->sql_query_limit($sql, 10);

参照

 * dbal.sql_build_array
 * dbal.sql_build_query
 * dbal.sql_query
 * Database Abstraction Layer
 * dbal.sql_fetchrow
 * dbal.sql_fetchrowset
 * dbal.sql_fetchfield

Dbal.sql_query_limit