All data displayed in the Flash movie (swf) using the fCMSPro components is stored in the database running on the web server. In order to retrieve specific data, based on a user's input, the Query object is used. You can access the Query class through ActionScript in order to create your own queries, in a similar way to the way you would execute an SQL query. When the data is retrieved, the fCMSPro will parse it transparently and trigger the appropriate events.
The fCMSPro
Query object is used for building up the query
that will be executed on the backend. It can be instantiated by using the
getQuery function of the
fMaster,
fTemplate or
fIndex components.
The Query class has a
toString
method that will output an easy to understand description of the query. By
using trace(myfTemplate.query); we can display this in the output window. It
should always be clear what queries the fIndex and fTemplate are sending to
the backend. Here are some examples:
Tracing the default query of fIndex component( trace( myfIndex.query ); )
outputs:
/------------------------------------
| select title
| from 0 to 5
| sort on $CREATIONTIME(date_time) DESC
| where $LANG = deflang
| AND $DOCTYPE = news
/------------------------------------
| select *
| from 0 to 5
| sort on $CREATIONTIME(date_time) DESC
| where $LANG = deflang
| AND $DOCTYPE = news
myfIndex.query.fields = [ "*" ];
myfIndex.query.setSort( "$ID", "number", "ASC" );
/------------------------------------
| select *
| from 0 to 5
| sort on $ID(number) ASC
| where $LANG = deflang
| AND $DOCTYPE = news
myfMaster.language = "english";
/------------------------------------
| select *
| from 0 to 5
| sort on $ID(number) ASC
| where $LANG = english
| AND $DOCTYPE = news
myfMaster.language = "english";
trace( myfMaster.getQuery() );
/------------------------------------
| select *
| from 0 to 5
| sort on $CREATIONTIME(date_time) DESC
| where $LANG = english
myfIndex.query.removeAllFilters();
myfIndex.query.addFilter( "$LANG", "=", "english");
myfIndex.query.addFilter( "$DOCTYPE", "=", "news");
/------------------------------------
| select *
| from 0 to 5
| sort on $ID(number) ASC
| where $LANG = english
| AND $DOCTYPE = news