Adobe ColdFusion 8

Writing the server-side ActionScript function

The example in this section creates a search function that performs a simple search operation against a ColdFusion data source. This function accepts two arguments, firstName and lastName, and returns any records found that match these arguments.

Create a server-side ActionScript function

  1. Create a server-side ActionScript file that contains the following code:
//search takes firstName lastName arguments
function search(firstName, lastName)
{
    searchdata = CF.query({datasource: "bigDSN", 
        sql:"SELECT * from personnel WHERE fname = firstName AND lname = lastName"{);

    if (searchdata)
        return searchdata;
    else
        return null;
}

  1. Save the file as personneldirectory.asr.