Adding custom columns to Propel model?
Posted
by
Hard-Boiled Wonderland
on Stack Overflow
See other posts from Stack Overflow
or by Hard-Boiled Wonderland
Published on 2012-12-12T11:13:02Z
Indexed on
2012/12/12
17:04 UTC
Read the original article
Hit count: 246
At the moment I am using the below query:
$claims = ClaimQuery::create('c')
->leftJoinUser()
->withColumn('CONCAT(User.Firstname, " ", User.Lastname)', 'name')
->withColumn('User.Email', 'email')
->filterByArray($conditions)
->paginate($page = $page, $maxPerPage = $top);
However I then want to add columns manually, so I thought this would simply work:
foreach($claims as &$claim){
$claim->actions = array('edit' => array(
'url' => $this->get('router')->generate('hera_claims_edit'),
'text' => 'Edit'
)
);
}
return array('claims' => $claims, 'count' => count($claims));
However when the data is returned Propel or Symfony2 seems to be stripping the custom data when it gets converted to JSON along with all of the superflous model data.
What is the correct way of manually adding data this way?
© Stack Overflow or respective owner