Skip to content
aaronbee edited this page Sep 14, 2010 · 3 revisions

To help with converting your apps from ActiveRecord there is now a pfind method on Rails models.

Its usage looks like this:
User.pfind(["userByName", "Sally"], [:all, :conditions => "name = Sally"])

It takes two arrays the first array is used if you are in PIQL mode and the second if you are in ActiveRecord mode. See below about modes.
The first array should have a PIQL query name followed by any arguments needed for that query.
The second array should have all the arguments you would pass to the normal ActiveRecord find method.

In PIQL mode the above is equivalent to Query.userByName("Sally").to_a. Notice the to_a. This is to ensure that the two possible return values of this method are of similar type. To read more about the return type of Query calls see Queries.

Modes

The following line at the top of config/environment.rb puts you in ActiveRecord mode:
USE_AR = true
If that line is either USE_AR = false or not there at all then you will be in PIQL mode.

Clone this wiki locally