package com.hongshee.ejforum.data.sql;

/**
 * <p>Title: MysqlAdapter.java</p>
 * <p>Description: MysqlAdapter</p>
 * <p>Copyright: Hongshee Software (c) 2007</p>
 * @author jackie du
 * @version 1.0
 */

import com.hongshee.ejforum.data.SqlAdapter;

public class MysqlAdapter extends SqlAdapter 
{
    public MysqlAdapter()
    {
    }
    
    public void init() throws Exception
    {}
    
    public String getPageQuerySql(StringBuilder sqlBuf, 
                                  int pageNo, int pageRows, int totalCount)
    {
        int[] pageParams = getPageQueryParams(pageNo, pageRows, totalCount);
        return sqlBuf.append(" limit ").append(pageParams[0])
                     .append(',').append(pageParams[1]).toString();
    }
    
    protected int[] getPageQueryParams(int pageNo, int pageRows, int totalCount)
    {
        int[] result = new int[2];
        int offset = (pageNo-1) * pageRows;
        result[0] = offset;
        result[1] = pageRows;
        return result;
    }
}
