次のコマンドを使用してテーブルを生成する際に問題が発生しました。
php symfony doctrine:insert-sql
次のエラーが返されます。
>> doctrine creating tables
Class "Complaint" must be a child class of Doctrine_Record
PHP Fatal error: Call to a member function evictAll() on a non-object in D:\Internet\PHP\ijzerleeuw_bezoekrapporten\lib\vendor\symfony\lib\plugins\sfDoctri
nePlugin\lib\vendor\doctrine\Doctrine\Connection.php on line 1239
PHP Stack trace:
PHP 1. {main}() D:\Internet\PHP\ijzerleeuw_bezoekrapporten\symfony:0
PHP 2. include() D:\Internet\PHP\ijzerleeuw_bezoekrapporten\symfony:14
PHP 3. sfDatabaseManager->shutdown() D:\Internet\PHP\ijzerleeuw_bezoekrapporten\lib\vendor\symfony\lib\database\sfDatabaseManager.class.php:0
PHP 4. sfDoctrineDatabase->shutdown() D:\Internet\PHP\ijzerleeuw_bezoekrapporten\lib\vendor\symfony\lib\database\sfDatabaseManager.class.php:134
PHP 5. Doctrine_Manager->closeConnection() D:\Internet\PHP\ijzerleeuw_bezoekrapporten\lib\vendor\symfony\lib\plugins\sfDoctrinePlugin\lib\database\sfDoctr
ineDatabase.class.php:165
PHP 6. Doctrine_Connection->close() D:\Internet\PHP\ijzerleeuw_bezoekrapporten\lib\vendor\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrin
e\Manager.php:580
PHP 7. Doctrine_Connection->clear() D:\Internet\PHP\ijzerleeuw_bezoekrapporten\lib\vendor\symfony\lib\plugins\sfDoctrinePlugin\lib\vendor\doctrine\Doctrin
e\Connection.php:1268
これは、モデルを生成するために使用したschema.ymlです(php symfony doctrine:build-mdeol):
InspectionReport:
actAs: { Timestampable: ~ }
columns:
customer_id: { type: integer(5), notnull: true }
username: { type: string(255), notnull: true }
start_time: { type: string(5) }
end_time: { type: string(5) }
type: { type: string(5) }
reason: { type: string(4) }
contact: { type: string(5) }
subject: { type: string(5) }
remarks: { type: string(5000) }
emailaddresses: { type: string(5) }
relations:
Complaints:
class: Complaint
refClass: ComplaintInspectionReport
local: id
foreign: complaint_id
Reviews:
class: Review
refClass: ReviewInspectionReport
local: id
foreign: review_id
ComplaintInspectionReport:
columns:
complaint_id: { type: integer(4), primary: true }
inspection_report_id: { type: integer, primary: true }
relations:
Complaint: { onDelete: CASCADE, local: complaint_id, foreign: id }
InspectionReport: { onDelete: CASCADE, local: inspection_report_id, foreign: id }
ReviewInspectionReport:
columns:
review_id: { type: integer, primary: true }
inspection_report_id: { type: integer, primary: true }
relations:
Review: { onDelete: CASCADE, local: review_id, foreign: id }
InspectionReport: { onDelete: CASCADE, local: inspection_report_id, foreign: id }
Complaint:
columns:
id: { type: integer, notnull: true }
description: { type: string(32), notnull: true }
contact: { type: string(32) }
remark: { type: string(50) }
Review:
columns:
id: { type: integer, notnull: true }
description: { type: string(32), notnull: true }
contact: { type: string(32) }
remark: { type: string(50) }
grade: { type: string(1) }
email_address: { type: string(32) }
そして、model / schemaから生成したschema.sql(php symfony doctrine:build-sql):
CREATE TABLE complaint (id BIGINT AUTO_INCREMENT, description VARCHAR(32) NOT NULL, contact VARCHAR(32), remark VARCHAR(50), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE complaint_inspection_report (complaint_id INT, inspection_report_id BIGINT, PRIMARY KEY(complaint_id, inspection_report_id)) ENGINE = INNODB;
CREATE TABLE inspection_report (id BIGINT AUTO_INCREMENT, customer_id BIGINT NOT NULL, username VARCHAR(255) NOT NULL, start_time VARCHAR(5), end_time VARCHAR(5), type VARCHAR(5), reason VARCHAR(4), contact VARCHAR(5), subject VARCHAR(5), remarks TEXT, emailaddresses VARCHAR(5), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE review (id BIGINT AUTO_INCREMENT, description VARCHAR(32) NOT NULL, contact VARCHAR(32), remark VARCHAR(50), grade VARCHAR(1), email_address VARCHAR(32), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE review_inspection_report (review_id BIGINT, inspection_report_id BIGINT, PRIMARY KEY(review_id, inspection_report_id)) ENGINE = INNODB;
ALTER TABLE complaint_inspection_report ADD CONSTRAINT complaint_inspection_report_complaint_id_complaint_id FOREIGN KEY (complaint_id) REFERENCES complaint(id) ON DELETE CASCADE;
ALTER TABLE complaint_inspection_report ADD CONSTRAINT ciii FOREIGN KEY (inspection_report_id) REFERENCES inspection_report(id) ON DELETE CASCADE;
ALTER TABLE review_inspection_report ADD CONSTRAINT riii FOREIGN KEY (inspection_report_id) REFERENCES inspection_report(id) ON DELETE CASCADE;
ALTER TABLE review_inspection_report ADD CONSTRAINT review_inspection_report_review_id_review_id FOREIGN KEY (review_id) REFERENCES review(id) ON DELETE CASCADE;
SQLを手動で実行すると正常に動作しますが、doctrine:insert-sqlを使用するとエラーが返されます。
スキーマのエラーを考えていますが、把握できないようです。あるいは、まったく違うものかもしれません。