Search code examples
phpsymfony1propel

How to have Propel ORM 1.6 created_at fields?


I tried to specify this field:

<column name="created_at" phpName="CreatedAt" type="TIMESTAMP" required="false"/>

However, whether it's required or not, Propel never seems to place the current date time on it. How do I specify that I want Propel to take care of this for me?


Solution

  • You should use the timestampable behavior:

    The timestampable behavior allows you to keep track of the date of creation and last update of your model objects.

    Using (by default):

    <behavior name="timestampable" />
    

    Or (if you want to customize field):

    <behavior name="timestampable">
      <parameter name="create_column" value="my_create_date" />
      <parameter name="update_column" value="my_update_date" />
    </behavior>