1
0
mirror of synced 2024-12-13 14:56:01 +03:00
doctrine2/tests_old/models/ClientModel.php

48 lines
2.0 KiB
PHP
Raw Normal View History

2007-07-20 23:17:58 +04:00
<?php
class ClientModel extends Doctrine_Entity
2007-07-20 23:17:58 +04:00
{
public static function initMetadata($class)
2007-07-20 23:17:58 +04:00
{
$class->setTableName('clients');
2007-07-20 23:17:58 +04:00
$class->setColumn('id', 'integer', 4, array('notnull' => true,
2007-07-20 23:17:58 +04:00
'primary' => true,
'autoincrement' => true,
'unsigned' => true));
$class->setColumn('short_name', 'string', 32, array('notnull' => true, 'notblank', 'unique' => true));
$class->hasMany('AddressModel', array('local' => 'client_id', 'foreign' => 'address_id', 'refClass' => 'ClientToAddressModel'));
2007-07-20 23:17:58 +04:00
}
}
class ClientToAddressModel extends Doctrine_Entity
2007-07-20 23:17:58 +04:00
{
public static function initMetadata($class)
2007-07-20 23:17:58 +04:00
{
$class->setTableName('clients_to_addresses');
2007-07-20 23:17:58 +04:00
$class->setColumn('client_id', 'integer', 11, array('primary' => true));
$class->setColumn('address_id', 'integer', 11, array('primary' => true));
$class->hasOne('ClientModel', array('local' => 'client_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
$class->hasOne('AddressModel', array('local' => 'address_id', 'foreign' => 'id', 'onDelete' => 'CASCADE'));
2007-07-20 23:17:58 +04:00
}
}
class AddressModel extends Doctrine_Entity
2007-07-20 23:17:58 +04:00
{
public static function initMetadata($class)
2007-07-20 23:17:58 +04:00
{
$class->setTableName('addresses');
2007-07-20 23:17:58 +04:00
$class->setColumn('id', 'integer', 11, array('autoincrement' => true,
2007-07-20 23:17:58 +04:00
'primary' => true
));
$class->setColumn('address1', 'string', 255, array('notnull' => true, 'notblank'));
$class->setColumn('address2', 'string', 255, array('notnull' => true));
$class->setColumn('city', 'string', 255, array('notnull' => true, 'notblank'));
$class->setColumn('state', 'string', 10, array('notnull' => true, 'notblank', 'usstate'));
$class->setColumn('zip', 'string', 15, array('notnull' => true, 'notblank', 'regexp' => '/^[0-9-]*$/'));
$class->hasMany('ClientModel', array('local' => 'address_id', 'foreign' => 'client_id', 'refClass' => 'ClientToAddressModel'));
2007-07-20 23:17:58 +04:00
}
}