mysql - Symfony 1.4 select query with selected columns is not working -
i want run following query in symfony doctrine.
select p.id id skichaletprice p ski_chalet_id = ? , month = ? i wrote doctrine query following.
$q = doctrine_query::create() ->select('p.id id') ->from('skichaletprice p') ->andwhere('ski_chalet_id = ?', $chaletid) ->andwhere('month = ?', $from); $result = $q->fetchone(); if ($result->count() > 0) { return $result->toarray(); } else { return null; } but result include columns in table. issue? please me.
the issue fetchone() return doctrine object, implicitly contains columns in table. $result->toarray() converting doctrine object array, why columns.
if want subset of column, don't hydrate object, instead this:
$q = doctrine_query::create() ->select('p.id id') ->from('skichaletprice p') ->andwhere('ski_chalet_id = ?', $chaletid) ->andwhere('month = ?', $from); $results = $q->execute(array(), doctrine::hydrate_scalar); see http://docs.doctrine-project.org/projects/doctrine1/en/latest/en/manual/data-hydrators.html
Comments
Post a Comment