public function dbInstall() { $db = Yii::$app->db; $tableOptions = null; if ($db->driverName === 'mysql') { $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=MyISAM'; } $db->createCommand()->createTable(Contact::tableName(), ['contact_id' => 'pk', 'title' => Schema::TYPE_STRING . '(120) NOT NULL', 'value' => Schema::TYPE_STRING . '(120) DEFAULT NULL', 'url' => Schema::TYPE_STRING . '(255) DEFAULT NULL', 'image' => Schema::TYPE_STRING . '(255) DEFAULT NULL', 'app_id' => Schema::TYPE_STRING . '(120) DEFAULT NULL', 'type' => Schema::TYPE_STRING . '(20) DEFAULT NULL', 'account_id' => Schema::TYPE_STRING . '(120) DEFAULT NULL', 'order_num' => Schema::TYPE_INTEGER . ' DEFAULT NULL', 'status' => 'tinyint(1) NOT NULL DEFAULT 1', 'created_at' => Schema::TYPE_INTEGER . ' unsigned NOT NULL', 'updated_at' => Schema::TYPE_INTEGER . ' unsigned NOT NULL'], $tableOptions)->execute(); }
public function actionDelete($id) { if ($model = Contact::findOne($id)) { $model->delete(); } else { $this->error = Yii::t('easyii', 'Not found'); } return $this->formatResponse(Yii::t('easyii/contact', 'News deleted')); }