我有一张简单的桌子。这是模型图片:

abstract class BaseImages extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->setTableName('images');
        $this->hasColumn('id', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => true,
             'autoincrement' => true,
             ));
        $this->hasColumn('file', 'string', 45, array(
             'type' => 'string',
             'length' => 45,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             ));
        $this->hasColumn('order', 'integer', 4, array(
             'type' => 'integer',
             'length' => 4,
             'fixed' => false,
             'unsigned' => false,
             'primary' => false,
             'default' => '0',
             'notnull' => false,
             'autoincrement' => false,
             ));
    }

    public function setUp()
    {
        parent::setUp();
        $this->hasMany('AuthorsHasImages', array(
             'local' => 'id',
             'foreign' => 'images_id'));

        $this->hasMany('Banners', array(
             'local' => 'id',
             'foreign' => 'images_id'));

        $this->hasMany('BooksHasImages', array(
             'local' => 'id',
             'foreign' => 'images_id'));

        $this->hasMany('Collections', array(
             'local' => 'id',
             'foreign' => 'images_id'));

        $this->hasMany('IllustratorsHasImages', array(
             'local' => 'id',
             'foreign' => 'images_id'));

        $this->hasMany('MerchandisingHasImages', array(
             'local' => 'id',
             'foreign' => 'images_id'));
    }
}

当我使用:
$image = new Images();
$image->file = $name;
$image->save();

我有以下错误:
致命错误:Uncaught exception'Doctrine_Connection_Mysql_exception'带有消息'SQLSTATE[42000]:语法错误或访问冲突:1064您的SQL语法有错误;请检查与您的Mysql服务器版本相对应的手册,以获取在'order,file)VALUES('0'附近使用的正确语法,'P8040001.JPG')'在/Users/maurogadaleta/Sites/org.blackiebooks/phpinc/docine/docine/Connection.php:1082堆栈跟踪:#0/Users/maurogadaleta/Sites/org.blackiebooks/phpinc/docine/docine/Connection/Statement.php(269):docine\Connection->rethrowException(Object(PDOException),对象(条令连接语句))#1/Users/maurogadaleta/Sites/org.blackiebooks/phpinc/docine/docine/Connection.php(1042):条令连接语句->执行(数组)#2/Users/maurogadaleta/Sites/org.blackiebooks/phpinc/docine/docine/Connection.php(687):条令连接->exec('插入ima…',数组)#3/Users/maurogadaleta/Sites/org.blackiebooks/phpinc/docine/docine/Connection/UnitOfWork.php(647):在线1082上的docine-in/Users/maurogadaleta/Sites/org.blackiebooks/phpinc/docine/docine/Connection.php
有人知道我为什么会犯这个错误,以及我能做些什么来解决这个问题吗?

最佳答案

使用标识符引用;

$conn->setAttribute(Doctrine_Core::ATTR_QUOTE_IDENTIFIER, true);

http://www.doctrine-project.org/documentation/manual/1_2/hu/configuration#identifier-quoting

08-03 18:37