src/snac/server/database/SQL.php
/**
     * Handle the strings for limit and offset
     *
     * This the logical implementation details in building limit and offset SQL statements. The defaults are
     * at a higher level, so checking here is merely to catch errors. If -1, do all, that is no limit or
     * offset statement. If an integer, use that as the limit or offset. If null then use the default, but
     * null should never happen because the default in the calling code is an integer constant from the
     * config.
     *
     * Default in the calling code are: \snac\Config::$SQL_LIMIT, \snac\Config::$SQL_OFFSET.
     *
     * Always return the string padded with leading and trailing spaces. It is safer to have extra spaces.
     *
     * @param string $str Either 'limit' or 'offset'
     *
     * @param integer $value An integer or -1. We accept null, but only as an error which results in using the
     * constants.
     *
     * @return string An empty string, or a limit or offset SQL string.
     */
Handle the strings for limit and offset
This the logical implementation details in building limit and offset SQL statements. The defaults are
at a higher level, so checking here is merely to catch errors. If -1, do all, that is no limit or
offset statement. If an integer, use that as the limit or offset. If null then use the default, but
null should never happen because the default in the calling code is an integer constant from the
config.



Always return the string padded with leading and trailing spaces. It is safer to have extra spaces.

@param string $str Either 'limit' or 'offset'

@param integer $value An integer or -1. We accept null, but only as an error which results in using the
constants.

@return string An empty string, or a limit or offset SQL string.
Handle the strings for limit and offset This the logical implementation details in building limit and offset SQL statements . The defaults are at a higher level so checking here is merely to catch errors . If - 1 do all that is no limit or offset statement . If an integer use that as the limit or offset . If null then use the default but null should never happen because the default in the calling code is an integer constant from the config . Always return the string padded with leading and trailing spaces . It is safer to have extra spaces . @param string $str Either ' limit ' or ' offset ' @param integer $value An integer or - 1 . We accept null but only as an error which results in using the constants . @return string An empty string or a limit or offset SQL string .
private function doLOValue($str, $value)
    {
        if ($value < 0 || ($str != 'limit' && $str != 'offset'))
        {
            return '';
        }
        elseif ($value == null || ! is_int($value))
        {
            if ($str == 'limit')
            {
                return " $str " . \snac\Config::$SQL_LIMIT . " ";
            }
            elseif ($str == 'offset')
            {
                return " $str " . \snac\Config::$SQL_OFFSET . " ";
            }
            else
            {
                return '';
            }
        }
        else
        {
            return " $str $value ";
        }
    }
private function doLOValue ( $ str , $ value ) { if ( $ value < 0 || ( $ str != 'limit' && $ str != 'offset' ) ) { return '' ; } elseif ( $ value == null || ! is_int ( $ value ) ) { if ( $ str == 'limit' ) { return " $ str " . \ snac \ Config :: $ SQL_LIMIT . " " ; } elseif ( $ str == 'offset' ) { return " $ str " . \ snac \ Config :: $ SQL_OFFSET . " " ; } else { return '' ; } } else { return " $ str $ value " ; } }
Handle the strings for limit and offset
 This the logical implementation details in building limit and offset SQL statements.
Handle the strings for limit and offset This the logical implementation details in building limit and offset SQL statements .
/*
             * -1 or any negative value is "all". Negative values don't get beyond the first if statement.
             */ /*
             * Null or weird stuff use the default. This seems the safe option.  This should never happen, but
             * if it does, we have backstopped the user doing something non-sensical.
             */ /*
                 * If the $str is unknown, there's no limit or offset string we can create, so just return an
                 * empty string. The $str is checked in the first if statement, so we should never get down
                 * here, which makes this a belt and suspenders situation.
                 */ /*
             * Else we have a nice integer, so we use that.
             */