views:

86

answers:

1

How do I programmatically attach a Doctrine Behaviour to a table dynamically created through $conn->export->createTable('MyTable', $definition)?

For example, if I have the following code:

$definition = array(
    'id' => array(
        'type' => 'integer',
        'primary' => true,
        'autoincrement' => true
    ),
    'name' => array(
        'type' => 'string',
        'length' => 255
    )
);

$conn->export->createTable('MyTable', $definition) ;

At this point I would need to attach a doctrine typical behaviour like Timestampable or Versionable to the newly created 'MyTable' table. Is it possible at all?

A: 

With createTable you directly create the table in your database (it is just a nice wrapper to not write the SQL). This is a more low level function.

Behaviours are defined in your models. You can think about them as some kind of hooks that come into play when you retrieve or store data via this model.

In your case, you don't even have a model. So long text short answer:

No it is not possible.

Felix Kling