私はDoctrineの関係に問題があります。 MySQLデータベース上で動作します。Mysqlの関係の問題、doctrineはこのエラーを受け取ります:Doctrine_Table_Exception:未知の関係エイリアスModel_Training
は私が私が思いついたことと何の上に座って何日かそれに飽き助けてください不明関係別名Model_Training、とGoogleはまた見つけることができませんでした:Doctrine_Table_Exception:関係を使用してデータをダウンロードする際に問題が私にこのエラーがスローされますが発生します何でもここ
を取得するコードであるデータ:
$dataRows = Doctrine_Query::create()
->from('Model_Training a')->where('a.idTrainings = ?', $this->_getParam('id'))
->leftJoin('a.Model_TrainingBonuse ac')
->leftJoin('a.Model_Bonuse ad')
->fetchArray();
教義のモデルの形成とschema.ymlファイル:
TrainingBonuse:
tableName: Trainings_has_Bonuses
columns:
Trainings_idTrainings:
type: integer(4)
notnull: true
autoincrement: true
Bonuses_idBonuses:
type: integer(4)
notnull: true
relations:
TrainingsIdTraining:
class: Training
local: Trainings_idTrainings
foreign: idTrainings
foreignAlias: Trainings_has_Bonuses
BonusesIdBonuse:
class: Bonuse
local: Bonuses_idBonuses
foreign: idBonuses
foreignAlias: Trainings_has_Bonuses
indexes:
fk_Trainings_has_Bonuses_Bonuses1:
fields: [Bonuses_idBonuses]
fk_Trainings_has_Bonuses_Trainings1:
fields: [Trainings_idTrainings]
options:
charset: utf8
collate: utf8_polish_ci
Bonuse:
tableName: Bonuses
columns:
idBonuses:
type: integer(4)
primary: true
notnull: true
autoincrement: true
name:
type: string(45)
title:
type: string(255)
description:
type: clob(65535)
file_url_full:
type: string(255)
file_type:
type: integer(1)
width_full:
type: integer(4)
height_full:
type: integer(4)
active:
type: integer(1)
default: 1
options:
charset: utf8
collate: utf8_polish_ci
Training:
tableName: Trainings
columns:
idTrainings:
type: integer(4)
primary: true
notnull: true
autoincrement: true
title:
type: string(255)
sub_title:
type: string(255)
up_body:
type: clob(65535)
training_body:
type: clob(65535)
question:
type: clob(65535)
opinion:
type: clob(65535)
bonuses:
type: integer(1)
notnull: true
default: 0
down_body:
type: clob(65535)
modyfication:
type: integer(1)
notnull: true
default: 0
active:
type: integer(1)
notnull: true
default: 1
options:
charset: utf8
collate: utf8_polish_ci
モデル:
TRAININGabstract class Model_Base_Training extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('Trainings');
$this->hasColumn('idTrainings', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('title', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('sub_title', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('up_body', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('training_body', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('question', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('opinion', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('bonuses', 'integer', 1, array(
'type' => 'integer',
'notnull' => true,
'default' => 0,
'length' => '1',
));
$this->hasColumn('down_body', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('modyfication', 'integer', 1, array(
'type' => 'integer',
'notnull' => true,
'default' => 0,
'length' => '1',
));
$this->hasColumn('active', 'integer', 1, array(
'type' => 'integer',
'notnull' => true,
'default' => 1,
'length' => '1',
));
$this->option('collate', 'utf8_polish_ci');
$this->option('charset', 'utf8');
$this->option('type', 'InnoDB');
}
public function setUp()
{
parent::setUp();
$this->hasMany('Model_UserTraining as Users_has_Trainings', array(
'local' => 'idTrainings',
'foreign' => 'Trainings_idTrainings'));
$this->hasMany('Model_TrainingBonuse as Trainings_has_Bonuses', array(
'local' => 'idTrainings',
'foreign' => 'Trainings_idTrainings'));
}
}
TRAINING_BONUSES
abstract class Model_Base_TrainingBonuse extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('Trainings_has_Bonuses');
$this->hasColumn('Trainings_idTrainings', 'integer', 4, array(
'type' => 'integer',
'notnull' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('Bonuses_idBonuses', 'integer', 4, array(
'type' => 'integer',
'notnull' => true,
'length' => '4',
));
$this->index('fk_Trainings_has_Bonuses_Bonuses1', array(
'fields' =>
array(
0 => 'Bonuses_idBonuses',
),
));
$this->index('fk_Trainings_has_Bonuses_Trainings1', array(
'fields' =>
array(
0 => 'Trainings_idTrainings',
),
));
$this->option('collate', 'utf8_polish_ci');
$this->option('charset', 'utf8');
$this->option('type', 'InnoDB');
}
public function setUp()
{
parent::setUp();
$this->hasOne('Model_Training as TrainingsIdTraining', array(
'local' => 'Trainings_idTrainings',
'foreign' => 'idTrainings'));
$this->hasOne('Model_Bonuse as BonusesIdBonuse', array(
'local' => 'Bonuses_idBonuses',
'foreign' => 'idBonuses'));
}
}
ボーナス
abstract class Model_Base_Bonuse extends Doctrine_Record
{
public function setTableDefinition()
{
$this->setTableName('Bonuses');
$this->hasColumn('idBonuses', 'integer', 4, array(
'type' => 'integer',
'primary' => true,
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('name', 'string', 45, array(
'type' => 'string',
'length' => '45',
));
$this->hasColumn('title', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('description', 'clob', 65535, array(
'type' => 'clob',
'length' => '65535',
));
$this->hasColumn('file_url_full', 'string', 255, array(
'type' => 'string',
'length' => '255',
));
$this->hasColumn('file_type', 'integer', 1, array(
'type' => 'integer',
'length' => '1',
));
$this->hasColumn('width_full', 'integer', 4, array(
'type' => 'integer',
'length' => '4',
));
$this->hasColumn('height_full', 'integer', 4, array(
'type' => 'integer',
'length' => '4',
));
$this->hasColumn('active', 'integer', 1, array(
'type' => 'integer',
'default' => 1,
'length' => '1',
));
$this->option('collate', 'utf8_polish_ci');
$this->option('charset', 'utf8');
$this->option('type', 'InnoDB');
}
public function setUp()
{
parent::setUp();
$this->hasMany('Model_TrainingBonuse as Trainings_has_Bonuses', array(
'local' => 'idBonuses',
'foreign' => 'Bonuses_idBonuses'));
}
}
ありがとうございました。すべて今はうまくいく。 – Tejek