We are using cakePHP 2.7.x.
The question I have is with overriding a core class -- or specifically adding functionality to a method without modifying the core code.
I need to add some functionality to the method:
cake/lib/Cake/Model/Datasource/DboSource->BuildColumn()
The docs say to put the whole class in the same location under app, and then the App loader will load it. So I copied the class to
marketplace/Model/Datasource/DboSource
and added my code snippet. Unfortunately nothing has changed.
If I add my change directly to the original method, everything works fine.
Context:
Inside that method all default values are quoted indiscriminately. Therefore something like DEFAULT CURRENT_TIMESTAMP
is interpreted and run as DEFAULT 'CURRENT_TIMESTAMP'
which obviously doesn't work as intended.
Specifically it is giving me the error "Syntax error or access violation: 1067 Invalid default value for 'created'"
when trying to cake bake a fixture.
I was directed to the cause of the problem, and a suggested fix for cakePHP 1.2.6, here: http://mamchenkov.net/wordpress/2010/04/21/unit-tests-with-cakephp/
According to the docs:
You can override almost every class in the framework, exceptions are the App and Configure classes. Whenever you like to perform such overriding, just add your class to your app/Lib folder mimicking the internal structure of the framework
So the path should be marketplace/Lib/Model/Datasource/DboSource
, not marketplace/Model/Datasource/DboSource