Creating a search tool with the Searchable behaviour in Doctrine

Once you’ve set up a searchable behaviour on a doctrine model, and have indexed all the keywords on the model, you are going to want to build a search tool. First we should create a simple symfony form.

Continue reading Creating a search tool with the Searchable behaviour in Doctrine

Re-indexing a doctrine object with a symfony task

Yesterday I explained how to add the Searchable behaviour to a doctrine object,  to I’ll cover that how to create a symfony task to re-index all the existing objects. The basic idea of the task is to retrieve all the objects from your database, mark them as dirty and re-save them. If you don’t mark them as dirty, nothing will update when you save, which is what you would expect from doctrine.

Continue reading Re-indexing a doctrine object with a symfony task

Adding the Searchable behaviour to a Doctrine model in Symfony

The searchable behaviour within Doctrine is a brilliant and powerful way to add a quick and simple search to your symfony code. The basics of this behaviour are to create an index table for your given model, which contains 4 things, a keyword, the field it was in, the position and the object id it was in.

Continue reading Adding the Searchable behaviour to a Doctrine model in Symfony

Michael Owen Online relaunch

Michael Owen OnlineThe DNS has migrated and the new code is online. The new version of Michael Owen Online has gone up with almost no problems. The only issues that were seen were 2 HTML files Google Webmaster tools looks for to prove you own the website, and a collection of wordpress URLs which were not identified and 301’d when the new code went up. As re-launch issues go they were pretty minor. Continue reading Michael Owen Online relaunch

Initial thoughts on Doctrine

I started to use Doctrine this year, and I have to say that I think I prefer it over Propel now on how you construct queries. The syntax is a little cleaner as well in my opinion. Here is an example of both syntaxes to retrieve a set of articles from a database which match a few criteria.

Propel:

$criteria = new Criteria('article a');
$criteria->add('a.status', 'active');
$criteria->add('a.type', 'news');
$criteria->addDescendingOrderByColumn('a.id');

Doctrine:

$query = new Doctrine_Query::create()
       ->from('article a')
       ->where('a.status = ?', 'active')
       ->andWhere('a.type = ?', 'news')
       ->addOrderBy('a.id DESC');

I also find the Doctrine way or building the query easier to read compared to the Propel one.

Once I’ve worked with Doctrine some more, and built some more complex queries I’ll add some more thoughts.