mysql - Doctrine 1 保存一行不归还保存的属性

标签 mysql doctrine doctrine-1.2

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

型号:

<?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);

它正在数据库中推送新条目,但没有给我新生成的行的属性。 这是一个奇怪的查询,但老实说,这浪费了我的时间。

最佳答案

太棒了,我刚刚用 YML 重新生成了模型,它就起作用了。

关于mysql - Doctrine 1 保存一行不归还保存的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26336746/

相关文章:

mysql - 理解 mysql_real_escape_string();

php - 如何使用 doctrine 在单个查询中获取整棵树?

php - 交响乐 3 : Doctrine dateTime problems row

php - 从 Doctrine_Collection 中删除项目

php - Doctrine 1.2 hydration 因 HYDRATION_RECORD 而失败,但适用于 HYDRATION_ARRAY

MySQL:InnoDB 上次修改时间

sql - 查找日期范围包含给定日期的行

java - 从数据库中保存和检索通过 jsp 给出的多个值

mysql - 将子查询转换为联接

php - 如何使用 Symfony 处理数据库 View ?