public function limit($sql, $count, $offset = 0)
    {
        $count = intval($count);
        if ($count < 0) {
            /** @see Zend_Db_Adapter_Exception */
            // require_once 'Zend/Db/Adapter/Exception.php';
            throw new Zend_Db_Adapter_Exception("LIMIT argument count=$count is not valid");
        } else if ($count == 0) {
              $limit_sql = str_ireplace("SELECT", "SELECT * FROM (SELECT", $sql);
              $limit_sql .= ") WHERE 0 = 1";
        } else {
            $offset = intval($offset);
            if ($offset < 0) {
                /** @see Zend_Db_Adapter_Exception */
                // require_once 'Zend/Db/Adapter/Exception.php';
                throw new Zend_Db_Adapter_Exception("LIMIT argument offset=$offset is not valid");
            }
            if ($offset == 0) {
                $limit_sql = str_ireplace("SELECT", "SELECT FIRST $count", $sql);
            } else {
                $limit_sql = str_ireplace("SELECT", "SELECT SKIP $offset LIMIT $count", $sql);
            }
        }
        return $limit_sql;
    }