You have found yourself in a bind, and you need to query the database directly. There is no other recourse than to write a query to get the data you need. This cookbook entry is going to give you some examples on how to use our new SugarQuery API instead of direct SQL.
1. What is SugarQuery?
SugarQuery is a SQL query builder for retrieving data directly from the database. It is used extensively within the core of the application. For instance, the FilterAPI uses it.
It uses a bean, the beans relationships, and visibility models to build a SQL query that can be used to retrieve data.
2. The Basics
SugarQuery has a very simple interface for building queries.
The basic methods you will need to create a query are:
- select($fields) – accepts an array of fields you would like to select
- from($bean) – validates the query against a SugarBean at generation
View original post 292 more words