select type_id, name, pretty_name, pretty_plural, name_pretty,
title_pretty, descr_pretty
from pb_types
where pkg_id = :pkg_id
order by sort_order
select name, pretty_name, datatype, widget, options
from pb_attributes
where type_id = :type_id
order by attribute_id