Book Image

Extending Symfony2 Web Application Framework

By : Sebastien Armand
Book Image

Extending Symfony2 Web Application Framework

By: Sebastien Armand

Overview of this book

Table of Contents (13 chapters)

Creating your own data types


Not all databases are created equal! MongoDB can store a collection of values or documents within a document, which is impossible in most relational databases. PostgreSQL can deal with geographical values, but MySQL can't.

For this reason, Doctrine only ships with a subset of standard supported types that are common across most of the databases. But, what if you want to use features specific to your database vendor or invent your own form of mapping type? You can define these types in exactly the same way Doctrine does.

User and meetup locations

We have already created a class named Coordinates to hold the latitude and longitude of a meetup. We have also created a query in our first controller to get a user only the events within a 50 km side square centered on them. There are a few problems with this; firstly, we can only use a square (or force the DB to do some calculation on each row), and secondly, there's no index on these queries, so it might slow down after...