Hi Julian,

> When executing SQL is there anyway just to get back a hash or array
> like the select_values method in ActiveRecord?
>
> I was trying to do order by count, same as this 
> messagehttp://groups.google.com/group/datamapper/browse_thread/thread/99b793...

Sure, just use:

  DataMapper.repository.adapter.query('SELECT field ....')

This will return an Array of Struct objects.

If you're fetching from a repository other than 'default' supply the
name to the repository method:

  DataMapper.repository(:name).adapter.query('SELECT field ....')

We also mix-in a repository() method into Kernel to allow the
shorthand form:

  repository.adapter.query('SELECT field ....')

Although I should mention that this automatic mix-in is going to be
going away in the DataMapper 0.10.0 series.  We'll still have a way to
do it (with a single require line), but I don't think DM should
automatically monkey-patch ruby core classes anymore.  It will be the
same for the Symbol operators too: opt-in only.

--

Dan
(dkubb)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to