使用CakePHP';s ORM,”;无法重新声明类Foo“;
以下是我的数据库结构:使用CakePHP';s ORM,”;无法重新声明类Foo“;,php,database,cakephp,orm,model,Php,Database,Cakephp,Orm,Model,以下是我的数据库结构: create table dpt_tutores ( id int primary key AUTO_INCREMENT, nivel varchar(128), apellidos varchar(256), nombres varchar(256), email varchar(512), estado varchar(128) ); create table dpt_grupos ( id int primary key AUTO_INCREMENT, fech
create table dpt_tutores
(
id int primary key AUTO_INCREMENT,
nivel varchar(128),
apellidos varchar(256),
nombres varchar(256),
email varchar(512),
estado varchar(128)
);
create table dpt_grupos
(
id int primary key AUTO_INCREMENT,
fecha_de_creacion datetime,
alumnos varchar(512),
titulo varchar(1024),
id_curso int,
informe_nota decimal(5,2),
informe_rango varchar(16),
predefensa_fecha datetime,
predefensa_gmt varchar(16),
predefensa_webex varchar(16),
defensa_fecha datetime,
defensa_gmt varchar(16),
defensa_webex varchar(16),
id_revisor int,
FOREIGN KEY (id_revisor) REFERENCES dpt_tutores(id),
id_guia int,
FOREIGN KEY (id_guia) REFERENCES dpt_tutores(id)
);
create table dpt_grupos_iteraciones
(
id int primary key AUTO_INCREMENT,
fecha datetime,
ubicacion_archivo varchar(512),
nota float(4,2),
id_grupo int,
FOREIGN KEY (id_grupo) REFERENCES dpt_grupos(id)
);
我添加了以下模型(dpt\u grupo.php
):
将模型文件重命名为
DptGrupo.php
$this->loadModel('DptGrupo');
$this->set('grupos', $this->DptGrupo->find('all'));
虽然Cake可以在不遵循约定的情况下正常工作,但它需要您做更多的工作来确保加载正确的内容。你可能想遵循惯例,先看看这是否管用。(模型名称没有下划线,由CamelCase引用,其文件名也用CamelCase表示。)
<?php
class DptController extends AppController {
public $helpers = array('Html', 'Form');
public function index() {
$this->loadModel('Dpt_Grupo');
$this->set('grupos', $this->dpt_grupo->find('all'));
}
}
$this->loadModel('DptGrupo');
$this->set('grupos', $this->DptGrupo->find('all'));