YiiFramework Связи между таблицами

Javelin

Новичок
есть 4 таблицы
CREATE TABLE `lpType` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`rule` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`route` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`view` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`lpName` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`lpBody` text COLLATE utf8_unicode_ci,
`lpMetaTitle` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`lpMetaKeywords` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`lpMetaDescription` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_slug` (`slug`)
) ENGINE=InnoDB AUTO_INCREMENT=30 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `lpWidget` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`landingPageId` int(11) unsigned DEFAULT NULL,
`blockId` int(11) unsigned NOT NULL,
`widgetId` int(11) unsigned NOT NULL,
`sort` smallint(6) unsigned NOT NULL DEFAULT '0',
`options` text COLLATE utf8_unicode_ci,
PRIMARY KEY (`id`),
KEY `K_lpId_blockId_sort` (`landingPageId`,`blockId`,`sort`),
KEY `K_blockId` (`blockId`),
KEY `K_widgetId` (`widgetId`),
CONSTRAINT `FK_lpBlock_id` FOREIGN KEY (`blockId`) REFERENCES `lpBlock` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `FK_lpWidget_landingPageId` FOREIGN KEY (`landingPageId`) REFERENCES `landingPage` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION,
CONSTRAINT `FK_widget_id` FOREIGN KEY (`widgetId`) REFERENCES `widget` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=292 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `lpBlock` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`typeId` int(11) unsigned NOT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_slug_typeId` (`slug`,`typeId`),
KEY `K_typeId` (`typeId`),
CONSTRAINT `FK_lpType_id` FOREIGN KEY (`typeId`) REFERENCES `lpType` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=157 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `landingPage` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`lpTypeId` int(11) unsigned NOT NULL,
`url` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`body` text COLLATE utf8_unicode_ci,
`metaTitle` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`metaKeywords` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`metaDescription` varchar(1000) COLLATE utf8_unicode_ci DEFAULT NULL,
`semanticKernel` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `UK_url` (`url`),
KEY `K_lpTypeId` (`lpTypeId`),
CONSTRAINT `FK_landingPage_lpTypeId` FOREIGN KEY (`lpTypeId`) REFERENCES `lpType` (`id`) ON DELETE CASCADE ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

стоит задача для модели landingPage создать метод
public function getLpBlocks()
{
}

* получить LpBlock-и для LandingPage
* два варианта:
* 1. через релейшн lpWidgets
* 2. блоки для LandingPage это блоки соответствующего LpType
* в чём разница между результатами вариантов?

или дайте ссылку на описание в доках

заранее смасибо
 
Сверху