Michael, I guess the code you wrote wouldn't work in Propel1.3. As far
as I'm concerned doSelectRS is not a case in Propel 1.3 anymore. One
should use doSelectStmt instead. If I were you I would try right that:
$c = new Criteria();
$c->clearSelectColumns();
$c->addSelectColumn( '((ACOS(SIN('.$zipcode->getLat().' * PI
() / 180) * SIN(`zipcodes`.LAT * PI() / 180) + COS('.$zipcode->getLat
().' * PI() / 180) * COS(`zipcodes`.LAT * PI() / 180) * COS(('.
$zipcode->getLon().' - `zipcodes`.LON) * PI() / 180)) * 180 / PI()) *
60 * 1.1515) as distance'); //Jesus Christ!
$sum = RoutesPeer::doSelectStmt($c);
$total = array();
while ($row = $sum->fetch(PDO::FETCH_NUM)) {
$total[] = array(
'distance' => $row[0],
//some other columns...
);
On Feb 28, 11:21 am, "[email protected]"
<[email protected]> wrote:
> doSelectRS is the right way to access an array.
> Example from propel docs:
>
> $rs = AuthorPeer::doSelectRS(new Criteria());
>
> $names = array();
>
> while($rs->next()) {
> $names[] = $rs->getString(2);
>
> }
>
> Michael
>
> On 28 Feb., 02:23, Joshua <[email protected]> wrote:
>
> > On Feb 27, 6:51 pm, Eno <[email protected]> wrote:
>
> > > On Fri, 27 Feb 2009, Joshua wrote:
> > > > $c = new Criteria();
> > > > $c->addAsColumn('distance', '((ACOS(SIN('.$zipcode->getLat().' * PI
> > > > () / 180) * SIN(`zipcodes`.LAT * PI() / 180) + COS('.$zipcode->getLat
> > > > ().' * PI() / 180) * COS(`zipcodes`.LAT * PI() / 180) * COS(('.
> > > > $zipcode->getLon().' - `zipcodes`.LON) * PI() / 180)) * 180 / PI()) *
> > > > 60 * 1.1515)');
> > > > RoutesPeer::addSelectColumns($c);
> > > > $c->setLimit(10);
> > > > $c->addAscendingOrderByColumn('distance');
> > > > $c->addJoin(ZipcodesPeer::ZIPCODE, RoutesPeer::ZIP_CODE);
> > > > $this->featuredRoutes = RoutesPeer::doSelect($c);
>
> > > > I need to be able to access "distance" column. The above code will
> > > > give me an array of Routes objects but does not include the distance
> > > > column.
>
> > > > What can I do to access all the necessary columns including custom
> > > > ones?
>
> > > I think, if you're using raw SQL inside a peer class, you will have to
> > > iterate through the rows and hydrate the objects yourself (I guess this
> > > also means you need the model classes and schema as well right?).
>
> > > --
>
> > I thought there was a way to have propel return the exact values as a
> > PHP array. Is that supposed to be done by doSelectRS maybe? It returns
> > an error when I try to use it?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---