I have a legacy database linked to a CakePHP (2.5.3) application. The database has a LOT of columns in all of its tables, many of which are completely unused (for example in one table I only need 2 columns out of 80 blank ones), so as a result I always have to specify 'fields' whenever I run a query. I read elsewhere that I can unset the fields by using code like this in the model:
function beforeFind($query) {
$this->schema();
unset($this->_schema['ColumnName']);
unset($this->_schema['ColumnName2']);
etc.
}
And this seems to work okay, the problem is that I am using 80+ lines of code to unset columns when really I only need to set two. Is there a way to force CakePHP to let me manually define the columns in the schema?
I have tried declaring the $_schema variable at the start of the model and that doesn't seem to help.