The simplest way to retrieve persistent peanuts from the database is to call one of the getPeanuts methods on the of the type:
- getPeanuts retrieves all instances,
- getPeanutWithId retrieves one by id.
- getPeanutsWith retrieves those with the value of a named property equal to the supplied value.
A little more complicated but much more flexible is to retrieve a prepared queryHandler from the classDescriptor by calling its . The queryHandler it returns will already hold the SELECT and FROM clause for the described class in its 'query' field. You may add more SQL to the 'query' field. Then you may get the peanuts using the query by calling the method on the classDecriptor. The classDescriptor will take care of caching the peanuts for the time your php script runs, and reuse peanuts from the cache if possible. Warning: this method may throw an exception if an error occurs!
Instead of manually writing the SQL, you may use to generate it. This is handy if you want to let the database sort the data according to the labelSort. It is also useful if you need to use relationships. See how to create and use filters.
Example 7 includes an example of retrieving peanuts using a queryHandler and filters.