php - Select specific column(s) using Propel without aliasing -
i'm having quite bit of trouble rewriting simple query using methods provided propel 1.6.
the query follows:
select type_id, count(id) `count` visit group type_id;
using propel, i've written following:
$visitcount = visitquery::create() ->withcolumn('count(id)', 'count') ->groupby('typeid') ->find();
this generates following query:
select visit.id, visit.job_id, visit.engineer_id, visit.type_id, visit.visit_date, visit.status, count(id) count `visit` group visit.type_id
which works, i need columns type_id
, count
, tried adding following:
$visits = visitquery::create() ->withcolumn('count(id)', 'count') ->select(array('typeid')) ->groupby('typeid') ->find();
this generates following (working) query:
select count(id) count, visit.type_id "typeid" `visit` group visit.type_id
however, don't want alias type_id
column. tried passing actual column name select
array (->select(array('type_id'))
), results in following query (which doesn't work):
select count(id) count, "type_id" `visit` group visit.type_id
how can retrieve type_id
column without being aliased?
propel abstracts column names php doesn't need know them.
from propelorm.org:
manipulating object model names allows detached actual data storage, , alter database names without updating php code.
typeid whatever phpname
equals in schema. try use opposed mysql column name.
with in mind, if want use actual name of columns can using propel's introspection classes. instance:
var_dump(visitpeer::gettablemap()->getcolumnbyphpname('typeid')->getname()); var_dump(visitpeer::gettablemap()->getcolumn('type_id')->getphpname());
but documentation says:
remember use phpname in php code