Для Propel версии 2 вы можете сделать следующее (в том же ключе, что и ответ j0k):
$fields = MyTableTableMap::getFieldNames("phpName");
/**
will give you (for example):
array (
'Id,
'Name',
'Content'
)
*/
// remove unwanted columns
$fields = array_values(array_diff($fields, ["Name"]));
$items = MyTableQuery::create()
->select(array_keys($fields))
->find();
Это можно легко превратить в функцию, если вам нужно делать это часто:
function exclude_fields($class, $exclude) {
$tableMap = $class::TABLE_MAP;
$fields = $tableMap::getFieldNames("phpName");
return array_values(array_diff($fields, $exclude));
}
$items = MyTableQuery::create()
->select(exclude_fields(MyTable::class, ["Name"]))
->find();