2010-04-10 75 views
1

我可以基於現有的數據庫生成我的模型和schema.yml文件。但是,當我嘗試做它周圍使用Doctrine::createTablesFromModels()其他方式,我得到一個錯誤:學說MYSQL 150+表:生成模型的作品,但反之亦然?

Syntax error or access violation: 1064

因此,無論這些作品:

Doctrine::generateYamlFromDb(APPPATH . 'models/yaml'); 
    Doctrine::generateYamlFromModels(APPPATH . 'models/yaml', APPPATH . 'models'); 
    Doctrine::generateModelsFromYaml(APPPATH . 'models/yaml', APPPATH . 'models', array('generateTableClasses' => true)); 
    Doctrine::generateModelsFromDb(APPATH . 'models', array('default'), array('generateTableClasses' => true)); 

但這種失敗(它滴/創建數據庫和周圍50個表):

Doctrine::dropDatabases(); 
    Doctrine::createDatabases(); 
    Doctrine::createTablesFromModels(); 

將部分輸出的SQL查詢顯示該錯誤是圍繞Notification對象看起來像這樣:

任何線索將不勝感激!

<?php 
// Connection Component Binding 
Doctrine_Manager::getInstance()->bindComponent('Notification', 'default'); 

/** 
* BaseNotification 
* 
* This class has been auto-generated by the Doctrine ORM Framework 
* 
* @property integer $n_auto_key 
* @property integer $type 
* @property string $title 
* @property string $message 
* @property timestamp $entry_date 
* @property timestamp $update_date 
* @property integer $u_auto_key 
* @property integer $c_auto_key 
* @property integer $ub_auto_key 
* @property integer $o_auto_key 
* @property integer $notified 
* @property integer $read 
* @property integer $urgence 
* 
* @package ##PACKAGE## 
* @subpackage ##SUBPACKAGE## 
* @author  ##NAME## <##EMAIL##> 
* @version SVN: $Id: Builder.php 6820 2009-11-30 17:27:49Z jwage $ 
*/ 
abstract class BaseNotification extends Doctrine_Record 
{ 
    public function setTableDefinition() 
    { 
     $this->setTableName('Notification'); 
     $this->hasColumn('n_auto_key', 'integer', 4, array(
      'type' => 'integer', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => true, 
      'autoincrement' => true, 
      'length' => '4', 
      )); 
     $this->hasColumn('type', 'integer', 1, array(
      'type' => 'integer', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      'length' => '1', 
      )); 
     $this->hasColumn('title', 'string', 50, array(
      'type' => 'string', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      'length' => '50', 
      )); 
     $this->hasColumn('message', 'string', null, array(
      'type' => 'string', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      'length' => '', 
      )); 
     $this->hasColumn('entry_date', 'timestamp', 25, array(
      'type' => 'timestamp', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      'length' => '25', 
      )); 
     $this->hasColumn('update_date', 'timestamp', 25, array(
      'type' => 'timestamp', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => false, 
      'autoincrement' => false, 
      'length' => '25', 
      )); 
     $this->hasColumn('u_auto_key', 'integer', 4, array(
      'type' => 'integer', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => true, 
      'autoincrement' => false, 
      'length' => '4', 
      )); 
     $this->hasColumn('c_auto_key', 'integer', 4, array(
      'type' => 'integer', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => false, 
      'autoincrement' => false, 
      'length' => '4', 
      )); 
     $this->hasColumn('ub_auto_key', 'integer', 4, array(
      'type' => 'integer', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => false, 
      'autoincrement' => false, 
      'length' => '4', 
      )); 
     $this->hasColumn('o_auto_key', 'integer', 4, array(
      'type' => 'integer', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'notnull' => false, 
      'autoincrement' => false, 
      'length' => '4', 
      )); 
     $this->hasColumn('notified', 'integer', 1, array(
      'type' => 'integer', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'default' => '0', 
      'notnull' => true, 
      'autoincrement' => false, 
      'length' => '1', 
      )); 
     $this->hasColumn('read', 'integer', 1, array(
      'type' => 'integer', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'default' => '0', 
      'notnull' => true, 
      'autoincrement' => false, 
      'length' => '1', 
      )); 
     $this->hasColumn('urgence', 'integer', 1, array(
      'type' => 'integer', 
      'fixed' => 0, 
      'unsigned' => false, 
      'primary' => false, 
      'default' => '0', 
      'notnull' => true, 
      'autoincrement' => false, 
      'length' => '1', 
      )); 
    } 

    public function setUp() 
    { 
     parent::setUp(); 

    } 
} 

回答

1

我使用保留字作爲列名(後來也如表名),似乎在「引用」選項學說並沒有被自動打開....