我有一個問題,使用命令生成我的表:類必須是一個子類Doctrine_Record誤差對PHP symfony的學說:插入-SQL
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的學說:內置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) }
我從模型/模式生成的schema.sql文件(PHP symfony的原則:建立-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手動它工作正常,但使用時學說:插入-SQL返回我的錯誤。
我在想我的模式中的錯誤,但似乎無法得到它的保留。或者,也許它完全不同。
你的模式沒問題。我們可以看到「投訴」模型類嗎? ('lib/model/doctrine/Complaint.class.php'&'lib/model/doctrine/ComplaintTable.class.php') – j0k
@ j0k我已經添加了模型。 –