protected function getNewSYSID($conn, $tableName, $includePrefix=false, $base=-1)
    {
        $maxRetry = 10;
        // try to update the table idbody column
        for ($try=1; $try <= $maxRetry; $try++)
        {
            $sql = "SELECT * FROM ob_sysids WHERE TABLENAME='$tableName'";
            try
            {
                $rs = $conn->query($sql);
            }
            catch (Exception $e)
            {
                throw new Exception("Error in query: " . $sql . ". " . $e->getMessage());
                return false;
            }
            $row = $rs->fetch();
            unset($rs);
            list($tblname, $prefix, $idbody) = $row;
            if (!$row)
                throw new Exception("Error in generating new system id: '$tableName' is not in ob_sysids table.");
            if ($row)
            {
                if ($idbody == null && $prefix) // idbody is empty, return false
                    throw new Exception("Error in generating new system id: ob_sysids table does not have a valid sequence for '$tableName'.");
            }
            // try to update the table idbody column
            $sql = "UPDATE ob_sysids SET IDBODY=IDBODY+1 WHERE TABLENAME='$tableName' AND IDBODY=$idbody";
            try
            {
                $rs = $conn->query($sql);
            }
            catch (Exception $e)
            {
                throw new Exception("Error in query: " . $sql . ". " . $e->getMessage());
                return false;
            }
            if ($rs->rowCount() > 0)
            {
                $idbody += 1;
                break;
            }
        }
        if ($try <= $maxRetry)
        {
            if ($base>=2 && $base<=36)
                $idbody = dec2base($idbody, $base);
            if ($includePrefix)
                return $prefix."_".$idbody;
            return $idbody;
        }
        else
            throw new Exception("Error in generating new system id: unable to get a valid id.");
        return false;
    }
protected function getNewSYSID($conn, $tableName, $includePrefix=false, $base=-1)
    {
        $maxRetry = 10;
        // try to update the table idbody column
        for ($try=1; $try <= $maxRetry; $try++)
        {
            $sql = "SELECT * FROM ob_sysids WHERE TABLENAME='$tableName'";
            try
            {
                $rs = $conn->query($sql);
            }
            catch (Exception $e)
            {
                throw new Exception("Error in query: " . $sql . ". " . $e->getMessage());
                return false;
            }
            $row = $rs->fetch();
            unset($rs);
            list($tblname, $prefix, $idbody) = $row;
            if (!$row)
                throw new Exception("Error in generating new system id: '$tableName' is not in ob_sysids table.");
            if ($row)
            {
                if ($idbody == null && $prefix) // idbody is empty, return false
                    throw new Exception("Error in generating new system id: ob_sysids table does not have a valid sequence for '$tableName'.");
            }
            // try to update the table idbody column
            $sql = "UPDATE ob_sysids SET IDBODY=IDBODY+1 WHERE TABLENAME='$tableName' AND IDBODY=$idbody";
            try
            {
                $rs = $conn->query($sql);
            }
            catch (Exception $e)
            {
                throw new Exception("Error in query: " . $sql . ". " . $e->getMessage());
                return false;
            }
            if ($rs->rowCount() > 0)
            {
                $idbody += 1;
                break;
            }
        }
        if ($try <= $maxRetry)
        {
            if ($base>=2 && $base<=36)
                $idbody = dec2base($idbody, $base);
            if ($includePrefix)
                return $prefix."_".$idbody;
            return $idbody;
        }
        else
            throw new Exception("Error in generating new system id: unable to get a valid id.");
        return false;
    }
protected function getNewSYSID ( $ conn , $ tableName , $ includePrefix = false , $ base = - 1 ) { $ maxRetry = 10 ; // try to update the table idbody column for ( $ try = 1 ; $ try <= $ maxRetry ; $ try ++ ) { $ sql = "SELECT * FROM ob_sysids WHERE TABLENAME='$tableName'" ; try { $ rs = $ conn -> query ( $ sql ) ; } catch ( Exception $ e ) { throw new Exception ( "Error in query: " . $ sql . ". " . $ e -> getMessage ( ) ) ; return false ; } $ row = $ rs -> fetch ( ) ; unset ( $ rs ) ; list ( $ tblname , $ prefix , $ idbody ) = $ row ; if ( ! $ row ) throw new Exception ( "Error in generating new system id: '$tableName' is not in ob_sysids table." ) ; if ( $ row ) { if ( $ idbody == null && $ prefix ) // idbody is empty, return false throw new Exception ( "Error in generating new system id: ob_sysids table does not have a valid sequence for '$tableName'." ) ; } // try to update the table idbody column $ sql = "UPDATE ob_sysids SET IDBODY=IDBODY+1 WHERE TABLENAME='$tableName' AND IDBODY=$idbody" ; try { $ rs = $ conn -> query ( $ sql ) ; } catch ( Exception $ e ) { throw new Exception ( "Error in query: " . $ sql . ". " . $ e -> getMessage ( ) ) ; return false ; } if ( $ rs -> rowCount ( ) > 0 ) { $ idbody += 1 ; break ; } } if ( $ try <= $ maxRetry ) { if ( $ base >= 2 && $ base <= 36 ) $ idbody = dec2base ( $ idbody , $ base ) ; if ( $ includePrefix ) return $ prefix . "_" . $ idbody ; return $ idbody ; } else throw new Exception ( "Error in generating new system id: unable to get a valid id." ) ; return false ; }
Get a new SYSID from the id_table. You can get SYSID for a table with prefix and base converting

@param \Zend_Db_Adapter_Abstract $conn database connection
@param string $tableName table name
@param boolean $includePrefix
@param integer $base to encode
@return string
Get a new SYSID from the id_table . You can get SYSID for a table with prefix and base converting