Yii Framework Forum: relations - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

relations

#1 User is offline   javelin2000 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 02-September 17

Posted 02 September 2017 - 12:56 PM

for landingPage model make method
public function getLpBlocks()
{
}

* receive LpBlock's for LandingPage
* 1. from relations with lpWidgets
* 2. block for LandingPage it is block's LpType
what is difference these two methods

thanc you in advance

tables here

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;
0

#2 User is offline   MetaCrawler 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 411
  • Joined: 12-February 11
  • Location:Germany

Posted 15 September 2017 - 03:38 AM

Hey,

... "please make this for me" is not how a forum works.
Please be more specific what your problem is / what part of the documentation you don't understand.

Best Regards
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users