保存功能在yii2中不起作用

时间:2016-04-06 22:07:20

标签: php

保存功能不适用于此型号,但它适用于同一项目中的所有其他型号我尝试了很多东西但它不起作用,我不知道什么是错的,它运行良好的一些几天前保存的数据,但现在不起作用了?

这是模型类

public interface I
{
    int ID { get; set; }
}

public class B : I
{
    public int ID { get; set; }
    public string PropB { get; set; }
}

public class A : B
{
    public string PropA { get; set; }

    public IEnumerable<I> GetListOfBase()
    {
        // Attempt #1
        var list1 = new List<I>();
        B b1 = this as B;
        list1.Add(b1);

        // Attempt #2
        var list2 = new List<I>();
        B b2 = (B)this.MemberwiseClone();
        list2.Add(b2);


        return list1;
    }
}

private static void TestGetListOfBase()
{
    var a = new A() { ID = 1, PropA = "aaa", PropB = "bbb" };
    var list = a.GetListOfBase();
}

此控制器类具有服务

<?php
namespace app\models;
class Post extends \yii\db\ActiveRecord
{
    public static function tableName()
    {
        return 'post';
    }
    public function rules()
    {
        array("owner , content , time" , "safe");
        return [
            [['owner', 'content', 'time'], 'required'],
            [['owner', 'time'], 'string', 'max' => 50],
            [['content'], 'string', 'max' => 255]
        ];
    }
    public function attributeLabels()
    {
        return [
            'postID' => 'Post ID',
            'owner' => 'Owner',
            'content' => 'Content',
            'time' => 'Time',
        ];
    }

    public function getNotifications()
    {
        return $this->hasMany(Notification::className(), 
    ['postID' =>          'postID']);
    }
    public function getOwner()
    {
        return $this->hasOne(Staff::className(), 
    ['formalemail' =>  'owner']);
    }
}

解决此问题的任何帮助?

0 个答案:

没有答案