public function limit($sql, $start, $qty = null)
    {
        if (is_null($qty)) {
            $qty = 50;
        }

        if (stripos($sql, ' LIMIT ') === false) {
            $sql = $sql . " LIMIT x OFFSET y";
        }

        return preg_replace(
            '~(\s[Ll][Ii][Mm][Ii][Tt])\s.*?\s([Oo][Ff][Ff][Ss][Ee][Tt])\s.*~',
            '$1 ' . $qty .' $2 ' .$start,
            $sql
        );
    }
public function limit($sql, $start, $qty = null)
    {
        if (is_null($qty)) {
            $qty = 50;
        }

        if (stripos($sql, ' LIMIT ') === false) {
            $sql = $sql . " LIMIT x OFFSET y";
        }

        return preg_replace(
            '~(\s[Ll][Ii][Mm][Ii][Tt])\s.*?\s([Oo][Ff][Ff][Ss][Ee][Tt])\s.*~',
            '$1 ' . $qty .' $2 ' .$start,
            $sql
        );
    }
public function limit ( $ sql , $ start , $ qty = null ) { if ( is_null ( $ qty ) ) { $ qty = 50 ; } if ( stripos ( $ sql , ' LIMIT ' ) === false ) { $ sql = $ sql . " LIMIT x OFFSET y" ; } return preg_replace ( '~(\s[Ll][Ii][Mm][Ii][Tt])\s.*?\s([Oo][Ff][Ff][Ss][Ee][Tt])\s.*~' , '$1 ' . $ qty . ' $2 ' . $ start , $ sql ) ; }
Given a SQL returns it with the proper LIMIT or equivalent method included
@param string $sql
@param int $start
@param int $qty
@return string
Given a SQL returns it with the proper LIMIT or equivalent method included