Tuesday, April 15, 2008

Writing PHP functions

We have started writing PHP functions that interact with the database. We are trying to keep our PHP as object oriented and reusable as we can. None of the functions read values directly from the GET or POST vars, instead they are passed them by a handler function. For testing, we put an HTML form in front of the PHP functions, but soon we will be calling them from within Flex.

Here's a screenshot of the HTML form in front of the getLoans function I wrote. It shows all the different optional filters we are using to select loans from the database.


While writing this function I learned that MySQL provides search functionality. You need to set up FULLTEXT keys for the items you want to be searchable, and then use MATCH () AGAINST() in the SELECT query. It supports natural language search and conditional search, where users enter symbols like +, -, "" to change the meaning of their keywords. It is apparently more efficient than using LIKE in the SELECT query, which could achieve a similar result.

No comments: