Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/253.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CakePHP:Bin蛋糕烘焙台不';不存在_Php_Cakephp - Fatal编程技术网

CakePHP:Bin蛋糕烘焙台不';不存在

CakePHP:Bin蛋糕烘焙台不';不存在,php,cakephp,Php,Cakephp,我使用迁移创建了一个表DeletedTransactions bin\cake bake migration CreateDeletedTransactions deleted_id:integer customer_id:integer description:text amount:decimal transaction_type_id:integer deleted_by:integer deleted_date:date 我可以看到它已在我的数据库中成功创建,并在我运行命令bin\ca

我使用迁移创建了一个表
DeletedTransactions

bin\cake bake migration CreateDeletedTransactions deleted_id:integer customer_id:integer description:text amount:decimal transaction_type_id:integer deleted_by:integer deleted_date:date
我可以看到它已在我的数据库中成功创建,并在我运行命令
bin\cake bake model
时列出

但是,当我尝试使用
bin\cake bake model DeletedTransactions
构建模型时,我得到以下错误:

找不到基表或视图:1146表“db.knowledgebasearticles”不存在

这是
知识库\u文章的结构:

CREATE TABLE knowledgebase_articles (
  id int(11) NOT NULL,
  title varchar(100) COLLATE utf8_bin DEFAULT NULL,
  content text COLLATE utf8_bin,
  kbcategory_id int(11) DEFAULT NULL,
  created_by int(11) DEFAULT NULL,
  created_date date DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
但这是数据库中的另一个表(顺便说一下,它确实存在…)

堆栈跟踪:

KnowledgebaseArticlesTable初始化()


您可以添加用于此操作的代码吗?@creyD ok我用迁移代码编辑了我的问题,Bake脚本寻找相关的表:DeletedTable(deleted_id)、CustomerTable(customer_id)、TransactionType(transaction_type_id),它就是
$this->setTable('knowledgebaseArticles')。。。表名应为
knowledgebase\u articles
。Bake需要检查所有表的架构,以便能够解析可能的
hasOne
hasMany
BelongToMany
关联,因为对于这些关联,可以从中推断信息的外键列,将驻留在另一个(关联)表中,而不是当前正在烘焙模型的表中(例如
comments
表中的
article\u id
将解析为
Articles hasmall comments
)。您可以添加用于此操作的代码吗?@creyD ok我用迁移代码编辑了我的问题。Bake脚本正在查找相关的表:DeletedTable(deleted_id)、CustomerTable(customer_id)、TransactionType(transaction_type_id),这就是
$this->setTable('knowledgebaseArticles')。。。表名应为
knowledgebase\u articles
。Bake需要检查所有表的架构,以便能够解析可能的
hasOne
hasMany
BelongToMany
关联,因为对于这些关联,可以从中推断信息的外键列,将驻留在另一个(关联)表中,而不是当前正在烘焙模型的表中(例如
comments
表中的
article\u id
将解析为
Articles hasmall comments
)。
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->setTable('knowledgebaseArticles');
        $this->setDisplayField('title');
        $this->setPrimaryKey('id');

        $this->belongsTo('UsersBy', [
            'foreignKey' => 'created_by',
            'className' => 'Users'
        ]);
        $this->belongsTo('KnowledgebaseArticlesCategories', [
            'foreignKey' => 'kbcategory_id'
        ]);
        $this->belongsToMany('Tags', [
            'foreignKey' => 'knowledgebase_article_id',
            'targetForeignKey' => 'tag_id',
            'joinTable' => 'knowledgebase_articles_tags'
        ]);
    }