Clear Cache

To content To menu To search

Tag - Doctrine

Entries feed - Comments feed

Thursday, January 21 2010

Customize Doctrine model builder options

This is just a little tip to customize the builder options for the generated model classes (lib/model/). Basically if we define a MyClass class in the schema.yml we will have this:
- MyClass > BaseMyClass > sfDoctrineRecord > Doctrine_Record > ...
- MyClassTable > Doctrine_Table > ...

Continue reading »

Thursday, November 26 2009

How to create a custom Doctrine behavior

So all is in the tittle ^^, in this post I will speak about a way to create your own Doctrine behavior. I really want to share this because it's the first time I create a behavior and I didn't really find any post about it with some complete exemple with code.

Before starting:
Why behavior could be very useful ? I think this well explained in the Doctrine documentation here ^^.

Why I wrote this post ? The Doctrine documentation contains very good explainations about the way of using temaples but I think it's blur about the way you can link a template and a generator in order to generate some classes on the fly.

Continue reading »

Friday, November 13 2009

Advanced filters with numbers for Doctrine. (fr and en)

Dernièrement j'ai du filtrer les nombres de façon supérieur ou inférieure sur un champ "prix", je me suis alors rendu compte que les filtres de Symfony avec Doctrine ne permettait pas cela, j'ai donc commençait à chercher une solution en me plongeant dans le code de Symfony, sans vraiment chercher sur internet je l'avoue, mais ça fait parfois du bien de voir comment marche l'outil que l'on utilise tous les jours ;) .

Lately I had to filter some numbers on a price field. The aim was to filter by bigger or smaller than the price value. I realized default Doctrine filters doesn't allow to do that, so I started to search a solution by looking at the Symfony code. I admint I don't really look on the internet to find a solution, but sometimes it's good to look inside the tool we use everyday ;).

Continue reading »

Friday, May 15 2009

SQLSTATE[HY000]: General error: 1005

SQLSTATE[HY000]: General error: 1005 Can't create table './ma_table/#sql-6d79_2523.frm' (errno: 150). Failing Query: ALTER TABLE table2 ADD FOREIGN KEY (table1) 
REFERENCES table1(id) ON DELETE SET NULL

Voilà une erreur qui m'est apparue plusieurs fois, assez embêtante lorsqu'on ne connait pas la solution.

Continue reading »

Tuesday, April 28 2009

Formulaires symfony: Traitement sur la valeur d'un champ à la sauvegarde

Voici une petite astuce permettant d'effectuer un traitement sur la valeur d'un champ lors de la sauvegarde d'un formulaire Doctrine ou Propel.

Imaginons par exemple une classe User avec deux attributs login et password de type string, password que nous allons sauvegarder en MD5 dans notre table user.

Pour enregistrer un utilisateur en base nous allons évidemment utiliser la classe de formulaire correspondant à notre classe User. Il serait donc pratique que lorsque l'on appelle la méthode save() de notre objet UserForm le mot de passe saisi par l'utilisateur dans le champ password soit automatiquement converti en MD5.

Continue reading »