本文整理汇总了PHP中Articles::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::setAttributes方法的具体用法?PHP Articles::setAttributes怎么用?PHP Articles::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::setAttributes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: safeUp
public function safeUp()
{
$this->execute("\n CREATE TABLE IF NOT EXISTS `Articles` (\n `id` int(11) NOT NULL AUTO_INCREMENT,\n `type` int(11) NOT NULL DEFAULT 0 COMMENT 'Тип статьи, см. Articles',\n `title` text NOT NULL DEFAULT '' COMMENT 'Заголовок',\n `text` text NOT NULL DEFAULT '' COMMENT 'Текст',\n `visible` tinyint(1) NOT NULL DEFAULT '1' COMMENT 'Видимость',\n PRIMARY KEY (`id`),\n KEY `type` (`type`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n ");
$this->execute("\n CREATE TABLE IF NOT EXISTS `Articles_lang` (\n `l_id` int(11) NOT NULL AUTO_INCREMENT,\n `articleId` int(11) NOT NULL,\n `lang_id` varchar(6) NOT NULL,\n `l_title` text NOT NULL default '',\n `l_text` text NOT NULL default '',\n PRIMARY KEY (`l_id`),\n KEY `menuId` (`articleId`),\n KEY `lang_id` (`lang_id`),\n CONSTRAINT `fk_articles_lang` FOREIGN KEY (`articleId`) REFERENCES `Articles` (`id`) ON DELETE CASCADE ON UPDATE CASCADE\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n ");
$article = new Articles();
$article->multilang();
$attr = array_merge($this->createLangData('title', 'В разработке', 'content'), $this->createLangData('text', 'Раздел находится в разработке', 'content'), array('type' => Articles::TYPE_UNDER_CONSTRUCTION));
$article->setAttributes($attr);
$article->save();
}
示例2: actionList_articles
public function actionList_articles()
{
if (Yii::app()->user->isGuest) {
$this->redirect($this->createAbsoluteUrl('default/index'));
}
$model = new Articles('search');
$model->unsetAttributes();
if (isset($_GET['Articles'])) {
$model->setAttributes($_GET['Articles'], false);
}
$category = Categorys::getAllCategories();
$menus = Mainmenu::model()->getDropDownMenu();
$this->render('articles/list_articles', array('model' => $model, 'menus' => $menus, 'category' => $category));
}