I have table name "classes" in database and when i create model with name "Class" ,it gives syntax error (obviously).Is there any way to remove this error without changing name of table in database ?
3条回答 默认 最新
- douyan1321 2013-07-29 14:16关注
I would stay away from a model named "Class", it is a keyword of php and it may will (as pointed by @AD7six) cause trouble if instantiated like that.
You can do the following:
class MyClass extends AppModel { public $useTable = 'classes'; }
Be sure that the controller ClassesController calls
MyClass
(with$uses
), but besides that, you can use the model like any other model without worrying about reserved keywords.本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报