how to build up the library..
Jacob Carlborg
doob at me.com
Fri Oct 7 12:02:06 PDT 2011
On 2011-10-07 15:34, Adam Ruppe wrote:
> What's the big advantage of
>
> Person.find_all_by_name_and_age("Joe", 15)
>
> over
>
> db.query("select * from people where name = ? and age = ?", "Joe", 15);
>
>
>
> The latter is much easier to write in the library and you retain all
> the flexibility of sql itself if needed.
I guess it just depends on what you like. I prefer to use the first
example. One advantage the first example could have would be to validate
the column names. If it already knows the column names it won't have to
query the database if the column names don't match.
Of course it should always be possible to execute raw sql queries, like
that last example.
I suggest you take a look at the documentation for ActiveRecord, just to
get a feel for the API:
http://guides.rubyonrails.org/active_record_querying.html
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list