In this post I’ll introduce you to extending Doctrine 2 to provide ways to use custom data types and DQL functions. We needed a simple way to store locations and calculate distances between points on maps and some other stuff for Wantlet. Since we are using MySQL, we decided to use MySQL’s Spatial Extensions for it since they seemed suitable. …
How to create Doctrine 1 -style Soft-Delete in Doctrine 2
Doctrine 1 has the concept of behaviors which you could add to your models. One of these was the soft-delete behavior, which allowed you to “delete” records without really deleting them. Doctrine 2 does not have behaviors due to various reasons. However, I needed a way to have a model which worked like soft-delete. Let’s see one approach to creating …
Doctrine vs. Propel: 2009 update
The best PHP ORM libraries, Doctrine and Propel. Last year I compared them to each other, and now it’s time to get a fresh look at how they have advanced in about a year – Is Doctrine still the better of the two? This time, I’ll also look at the features of each in more depth.
Optimizing Zend Framework and Doctrine applications
I decided to try profiling my quiz application to see if I could speed it up. Not surprisingly, biggest performance penalties came from loading classes and Doctrine’s ORM magic. Here are some findings on how to improve performance.
Decoupling models from the database: Data Access Object pattern in PHP
Data Access Object pattern: It’s a pattern which abstracts the details of the storage mechanism – be it a relational database, OO database, an XML file or whatever. The advantage of this is that you can easily implement different methods to persist objects without having to rewrite parts of your code.
Programming language guessing game
Some of you asked me about the “quiz” thing that showed up in one of the screenshots in my NetBeans review… Well, here it is: During that weekend when I was trying out NetBeans, I wrote a small Zend Framework + Doctrine application which attempts to guess a programming language the user is thinking of, based on a set of …
Understanding Doctrine’s NestedSet feature
The Doctrine library comes with a feature called nested set, which makes saving trees in a database easy. However, it’s quite easy to accidentally cause a lot of extra unneeded queries if not being careful. Here are some pointers to keep in mind while working with the nested set, and some example queries to make understanding it easier.
Zend_Form’s from Doctrine models: Part 2
Previously I wrote about my class for generating Zend_Form forms from Doctrine models. This time, let’s look at some more usage examples and how it works internally, to make it easier for you to utilize it. Edit 10.10.2008: Updated the post to reflect some minor changes in the CU_ModelForm class
Autogenerating forms from Doctrine models
In a previous post I mentioned how Django’s model forms are awesome. I really like the idea of being able to generate forms automatically from models – I mean the models already should contain most of the data you’d need: the fields, field types and how they will be stored. Since I was already quite familiar with Doctrine’s internals, I …