原则1挽救一场争吵而不归还被挽救的财产



在模型中新插入后,我发现在获取保存的属性时存在问题。

型号:

<?php
abstract class BaseTeacher extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->setTableName('teacher');
        $this->hasColumn('id', 'integer', null, array(
             'unique' => true,
             'primary' => true,
             'type' => 'integer',
             'autoincrement' => true,
             ));
        $this->hasColumn('website', 'string', 512, array(
             'type' => 'string',
             'autoincrement' => true,
             'length' => '512',
             ));
        $this->hasColumn('doj', 'date', null, array(
             'primary' => true,
             'type' => 'date',
             ));
        $this->hasColumn('isPermanent', 'boolean', null, array(
             'default' => 0,
             'type' => 'boolean',
             ));
        $this->hasColumn('isTeaching', 'boolean', null, array(
             'default' => 0,
             'type' => 'boolean',
             ));
        $this->hasColumn('empId', 'string', 512, array(
             'type' => 'string',
             'length' => '512',
             ));
        $this->hasColumn('qualification', 'string', 512, array(
             'type' => 'string',
             'length' => '512',
             ));
        $this->hasColumn('prevExperience', 'clob', null, array(
             'type' => 'clob',
             ));
        $this->hasColumn('status', 'string', 32, array(
             'type' => 'string',
             'length' => '32',
             ));
        $this->hasColumn('college_id', 'integer', null, array(
             'type' => 'integer',
             ));
        $this->hasColumn('user_id', 'integer', null, array(
             'type' => 'integer',
             ));
    }
    public function setUp()
    {
        parent::setUp();
        $softdelete0 = new Doctrine_Template_SoftDelete(array(
             'name' => 'deleted',
             'type' => 'boolean',
             'options' => 
             array(
              'default' => 0,
              'notnull' => true,
             ),
             ));
        $timestampable0 = new Doctrine_Template_Timestampable(array(
             'created' => 
             array(
              'name' => 'created_at',
              'type' => 'timestamp',
             ),
             'updated' => 
             array(
              'name' => 'updated_at',
              'type' => 'timestamp',
             ),
             ));
        $this->actAs($softdelete0);
        $this->actAs($timestampable0);
    }
}

**这是我的代码:**

$teacher                  = new Teacher();
$teacher->college_id      = $collegeId;
$teacher->user_id         = $user->id;
$teacher->save();
print_r($teacher->id);

它在DB中推送新条目,但没有给我新生成的行的属性。这是一个奇怪的问题,但老实说,这消磨了我的时间。

我刚刚用YML重新生成了模型,真是太棒了。

最新更新