I just want to select all fields except one field in cakephp 3.
Ex. $this->select(\'fname\', \'lname\', \'mname\', \'email\', \'password\', \'status\', \'crea
You could just find all and then at runtime hide what you dont need
$model->hiddenProperties(['modified', 'created']);
As of CakePHP 3.6 the selectAllExcept()
method has been introduced, which will select all columns from the schema that belongs to the given table, except those columns passed in the second argument:
$query->selectAllExcept($table, ['modified', 'created']);
In earlier versions you'd have to do that manually, ie grab all the possible columns from the schema and remove those that you don't want to include, like:
$query->select(
array_diff($table->schema()->columns(), ['modified', 'created']);
);
On a related note, check the following issue that asks for a deselect functionality: https://github.com/cakephp/cakephp/issues/6904
See also