Updates to sandbox and manual.
This commit is contained in:
parent
1bbc5b15ee
commit
90fd42291e
@ -51,30 +51,86 @@ $data->importDummyData($numRecords, $models);
|
|||||||
|
|
||||||
++ Writing
|
++ Writing
|
||||||
|
|
||||||
You can write your fixtures files manually and load them in to your applications. Below is a sample data.yml fixtures file
|
You can write your fixtures files manually and load them in to your applications. Below is a sample data.yml fixtures file. You can also split your data fixtures file up in to multiple files. Doctrine will read all fixtures files and parse them, then load all data.
|
||||||
|
|
||||||
|
Please see the [doc schema-files :index :name] for the sample models/schema for these example fixtures.
|
||||||
|
|
||||||
<code type="yml">
|
<code type="yml">
|
||||||
---
|
---
|
||||||
Email:
|
Adult:
|
||||||
Email_1:
|
Adult_1:
|
||||||
address: jwage@mac.com
|
name: Parent 1
|
||||||
Group:
|
Contact: Contact_1
|
||||||
Group_1:
|
Car:
|
||||||
name: Drama Actors
|
Car_1:
|
||||||
|
name: Chevorlet Trailblazer
|
||||||
|
Car_2:
|
||||||
|
name: Chevorlet Blazer
|
||||||
|
Car_3:
|
||||||
|
name: Buick
|
||||||
|
Child:
|
||||||
|
Child_1:
|
||||||
|
name: Child 1
|
||||||
|
Adult: Adult_1
|
||||||
|
Contact:
|
||||||
|
Contact_1:
|
||||||
|
name: Jonathan H. Wage
|
||||||
|
Contact_3:
|
||||||
|
name: Daniel Adams
|
||||||
|
Contact_4:
|
||||||
|
name: Robert Adams
|
||||||
|
Dog:
|
||||||
|
Dog_1:
|
||||||
|
name: Sam
|
||||||
|
User: User_1
|
||||||
|
Dog_2:
|
||||||
|
name: Dixie
|
||||||
|
User: User_2
|
||||||
|
Dog_3:
|
||||||
|
name: Chief
|
||||||
|
User: User_3
|
||||||
|
SelfReference:
|
||||||
|
SelfReference_1:
|
||||||
|
User1: User_1
|
||||||
|
User2: User_2
|
||||||
|
name: Self Reference 1
|
||||||
|
SelfReference1: SelfReference_2
|
||||||
|
SelfReference2: SelfReference_3
|
||||||
|
SelfReference_2:
|
||||||
|
User1: User_2
|
||||||
|
User2: User_1
|
||||||
|
name: Self Reference 2
|
||||||
|
SelfReference1: SelfReference_1
|
||||||
|
SelfReference2: SelfReference_1
|
||||||
|
SelfReference_3:
|
||||||
|
User1: User_2
|
||||||
|
User2: User_1
|
||||||
|
name: Self Reference 3
|
||||||
|
SelfReference1: SelfReference_3
|
||||||
|
SelfReference2: SelfReference_3
|
||||||
User:
|
User:
|
||||||
User_1:
|
User_1:
|
||||||
Phonenumber: Phonenumber_1
|
username: jwage
|
||||||
name: Jonathan H. Wage
|
hair_color: light brown
|
||||||
loginname: jwage
|
Contact: Contact_1
|
||||||
Email: Email_1
|
User_2:
|
||||||
Groupuser:
|
username: dadams
|
||||||
Groupuser_1:
|
hair_color: dark brown
|
||||||
Group: Group_1
|
Contact: Contact_3
|
||||||
|
User_3:
|
||||||
|
username: radams
|
||||||
|
hair_color: light brown
|
||||||
|
Contact: Contact_4
|
||||||
|
UserCar:
|
||||||
|
UserCar_1:
|
||||||
User: User_1
|
User: User_1
|
||||||
Phonenumber:
|
Car: Car_1
|
||||||
Phonenumber_1:
|
UserCar_2:
|
||||||
phonenumber: 555-555-5555
|
User: User_2
|
||||||
Group: Group_1
|
Car: Car_2
|
||||||
|
UserCar_3:
|
||||||
|
User: User_3
|
||||||
|
Car: Car_3
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
Here is how you would write code to load the data from that data.yml file
|
Here is how you would write code to load the data from that data.yml file
|
||||||
|
@ -2,50 +2,20 @@
|
|||||||
|
|
||||||
The purpose of schema files is to allow you to manage your model definitions directly from a yaml file rather then editing php code. The yaml schema file is parsed and used to generate all your model definitions/classes.
|
The purpose of schema files is to allow you to manage your model definitions directly from a yaml file rather then editing php code. The yaml schema file is parsed and used to generate all your model definitions/classes.
|
||||||
|
|
||||||
|
Schema files support all the normal things you would write with manual php code. Component to connection binding, relationships, attributes, templates/behaviors, indexes, etc.
|
||||||
|
|
||||||
++ Example Schema File
|
++ Example Schema File
|
||||||
|
|
||||||
'tableName' and 'className' are optional. If not specified they will be set by the key of the yaml block
|
Below is an example schema file for generating a set of models.
|
||||||
|
|
||||||
|
You will notice in this schema file it is not always necessary to specify the local and foreign parameters on a relationship. If the foreign columns follow the naming patterns, Doctrine can successfully guess each of them.
|
||||||
|
|
||||||
schema.yml
|
schema.yml
|
||||||
<code type="yml">
|
<code type="yml">
|
||||||
---
|
---
|
||||||
User:
|
|
||||||
columns:
|
|
||||||
id:
|
|
||||||
notnull: true
|
|
||||||
primary: true
|
|
||||||
autoincrement: true
|
|
||||||
type: integer
|
|
||||||
length: 4
|
|
||||||
name: id
|
|
||||||
username:
|
|
||||||
type: string
|
|
||||||
length: 255
|
|
||||||
relations:
|
|
||||||
Groups:
|
|
||||||
class: Group
|
|
||||||
refClass: UserGroup
|
|
||||||
local: user_id
|
|
||||||
foreign: group_id
|
|
||||||
type: many
|
|
||||||
UserGroup:
|
|
||||||
columns:
|
|
||||||
user_id:
|
|
||||||
type: integer
|
|
||||||
length: 4
|
|
||||||
primary: true
|
|
||||||
group_id:
|
|
||||||
type: integer
|
|
||||||
length: 4
|
|
||||||
primary: true
|
|
||||||
relations:
|
|
||||||
User:
|
|
||||||
local: user_id
|
|
||||||
foreign: id
|
|
||||||
Group:
|
|
||||||
local: group_id
|
|
||||||
foreign: id
|
|
||||||
Group:
|
Group:
|
||||||
|
# bind this model to connection1
|
||||||
|
connection: connection1
|
||||||
columns:
|
columns:
|
||||||
id:
|
id:
|
||||||
notnull: true
|
notnull: true
|
||||||
@ -61,12 +31,203 @@ Group:
|
|||||||
Users:
|
Users:
|
||||||
class: User
|
class: User
|
||||||
refClass: UserGroup
|
refClass: UserGroup
|
||||||
local: group_id
|
# set attributes on the model
|
||||||
foreign: user_id
|
attributes:
|
||||||
type: many
|
export: tables
|
||||||
|
# you can set templates on your schema with the following syntax
|
||||||
|
# if you do not require any options to be set for the template
|
||||||
|
# actAs and templates are the same, actAs serves as a convenience method for the Templates/Plugins
|
||||||
|
# that come bundled with Doctrine
|
||||||
|
templates: [Doctrine_Template_NestedSet, Doctrine_Template_Versionable]
|
||||||
|
# this below syntax can be used for the templates above
|
||||||
|
actAs:
|
||||||
|
NestedSet:
|
||||||
|
hasManyRoots: true
|
||||||
|
rootColumnName: root_id
|
||||||
|
UserGroup:
|
||||||
|
columns:
|
||||||
|
user_id:
|
||||||
|
type: integer
|
||||||
|
length: 4
|
||||||
|
primary: true
|
||||||
|
group_id:
|
||||||
|
type: integer
|
||||||
|
length: 4
|
||||||
|
primary: true
|
||||||
|
relations:
|
||||||
|
User: -
|
||||||
|
Group: -
|
||||||
|
UserCar:
|
||||||
|
columns:
|
||||||
|
user_id:
|
||||||
|
type: integer
|
||||||
|
length: 11
|
||||||
|
primary: true
|
||||||
|
car_id:
|
||||||
|
type: integer
|
||||||
|
length: 11
|
||||||
|
primary: true
|
||||||
|
relations:
|
||||||
|
User: -
|
||||||
|
Car: -
|
||||||
|
Adult:
|
||||||
|
fields:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
size: 255
|
||||||
|
contact_id:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
relations:
|
||||||
|
Contact:
|
||||||
|
foreignType: one
|
||||||
|
Car:
|
||||||
|
columns:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
length: 11
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
length: 255
|
||||||
|
relations:
|
||||||
|
Users:
|
||||||
|
class: User
|
||||||
|
refClass: UserCar
|
||||||
|
Child:
|
||||||
|
fields:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
size: 255
|
||||||
|
adult_id:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
relations:
|
||||||
|
Adult:
|
||||||
|
foreignAlias: Children
|
||||||
|
Contact:
|
||||||
|
columns:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
length: 11
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
length: 255
|
||||||
|
Dog:
|
||||||
|
columns:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
length: 11
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
length: 255
|
||||||
|
user_id:
|
||||||
|
type: integer
|
||||||
|
length: 11
|
||||||
|
relations:
|
||||||
|
User:
|
||||||
|
foreignType: one
|
||||||
|
SelfReference:
|
||||||
|
fields:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
size: 255
|
||||||
|
user_id1:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
user_id2:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
parent_self_reference_id:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
parent_self_reference_id2:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
relations:
|
||||||
|
User1:
|
||||||
|
class: User
|
||||||
|
local: user_id1
|
||||||
|
foreignAlias: SelfReference1
|
||||||
|
User2:
|
||||||
|
class: User
|
||||||
|
local: user_id2
|
||||||
|
foreignAlias: SelfReference2
|
||||||
|
SelfReference1:
|
||||||
|
class: SelfReference
|
||||||
|
local: parent_self_reference_id
|
||||||
|
foreignAlias: SelfReferences1
|
||||||
|
SelfReference2:
|
||||||
|
class: SelfReference
|
||||||
|
local: parent_self_reference_id2
|
||||||
|
foreignAlias: SelfReferences2
|
||||||
|
User:
|
||||||
|
inheritance:
|
||||||
|
extends: Entity
|
||||||
|
fields:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
|
username:
|
||||||
|
type: string
|
||||||
|
length: 255
|
||||||
|
hair_color:
|
||||||
|
type: string
|
||||||
|
length: 255
|
||||||
|
contact_id:
|
||||||
|
type: integer
|
||||||
|
length: 11
|
||||||
|
relations:
|
||||||
|
Contact:
|
||||||
|
local: contact_id
|
||||||
|
foreign: id
|
||||||
|
foreignType: one
|
||||||
|
Cars:
|
||||||
|
class: Car
|
||||||
|
refClass: UserCar
|
||||||
|
Groups:
|
||||||
|
class: Group
|
||||||
|
refClass: UserGroup
|
||||||
|
indexes:
|
||||||
|
name_x:
|
||||||
|
columns:
|
||||||
|
username:
|
||||||
|
sorting: ASC
|
||||||
|
length: 11
|
||||||
|
primary: true
|
||||||
|
type: unique
|
||||||
|
Entity:
|
||||||
|
columns:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
And now we want to use some Doctrine code to parse that schema yml file and generate our models from it
|
And now we want to use some Doctrine code to parse that schema.yml file and generate our models from it.
|
||||||
|
|
||||||
<code type="php">
|
<code type="php">
|
||||||
// This code will generate the models for schema.yml at /path/to/generate/models
|
// This code will generate the models for schema.yml at /path/to/generate/models
|
||||||
@ -74,124 +235,34 @@ $import = new Doctrine_Import_Schema();
|
|||||||
$import->importSchema('schema.yml', 'yml', '/path/to/generate/models');
|
$import->importSchema('schema.yml', 'yml', '/path/to/generate/models');
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
This is the directory structure that would be generated at /path/to/generate/models
|
This is the directory structure that would be generated at /path/to/generate/models. The base classes contain the actual definitions for the model, and the top level models extend the base and they are only written the first time so you are able to modify them without your additions being overwritten.
|
||||||
|
|
||||||
<code>
|
<code>
|
||||||
|
- Adult.class.php
|
||||||
|
- Car.class.php
|
||||||
|
- Child.class.php
|
||||||
|
- Contact.class.php
|
||||||
|
- Dog.class.php
|
||||||
|
- Entity.class.php
|
||||||
- Group.class.php
|
- Group.class.php
|
||||||
|
- SelfReference.class.php
|
||||||
- User.class.php
|
- User.class.php
|
||||||
|
- UserCar.class.php
|
||||||
- UserGroup.class.php
|
- UserGroup.class.php
|
||||||
- generated
|
- generated
|
||||||
|
- BaseAdult.class.php
|
||||||
|
- BaseCar.class.php
|
||||||
|
- BaseChild.class.php
|
||||||
|
- BaseContact.class.php
|
||||||
|
- BaseDog.class.php
|
||||||
|
- BaseEntity.class.php
|
||||||
- BaseGroup.class.php
|
- BaseGroup.class.php
|
||||||
|
- BaseSelfReference.class.php
|
||||||
- BaseUser.class.php
|
- BaseUser.class.php
|
||||||
|
- BaseUserCar.class.php
|
||||||
- BaseUserGroup.class.php
|
- BaseUserGroup.class.php
|
||||||
</code>
|
</code>
|
||||||
|
|
||||||
And finally here is the code for each of the generated models
|
|
||||||
|
|
||||||
<code type="php">
|
|
||||||
|
|
||||||
// Group.class.php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class has been auto-generated by the Doctrine ORM Framework
|
|
||||||
*/
|
|
||||||
class Group extends BaseGroup
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// User.class.php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class has been auto-generated by the Doctrine ORM Framework
|
|
||||||
*/
|
|
||||||
class User extends BaseUser
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserGroup.class.php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class has been auto-generated by the Doctrine ORM Framework
|
|
||||||
*/
|
|
||||||
class UserGroup extends BaseUserGroup
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// BaseGroup.class.php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class has been auto-generated by the Doctrine ORM Framework
|
|
||||||
*/
|
|
||||||
abstract class BaseGroup extends sfDoctrineRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
public function setTableDefinition()
|
|
||||||
{
|
|
||||||
$this->setTableName('group');
|
|
||||||
$this->hasColumn('id', 'integer', 4, array('notnull' => true,
|
|
||||||
'primary' => true,
|
|
||||||
'autoincrement' => true));
|
|
||||||
$this->hasColumn('name', 'string', 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
$this->hasMany('User as Users', array('refClass' => 'UserGroup',
|
|
||||||
'local' => 'group_id',
|
|
||||||
'foreign' => 'user_id'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// BaseUser.class.php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class has been auto-generated by the Doctrine ORM Framework
|
|
||||||
*/
|
|
||||||
abstract class BaseUser extends sfDoctrineRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
public function setTableDefinition()
|
|
||||||
{
|
|
||||||
$this->setTableName('user_table');
|
|
||||||
$this->hasColumn('id', 'integer', 4, array('notnull' => true,
|
|
||||||
'primary' => true,
|
|
||||||
'autoincrement' => true));
|
|
||||||
$this->hasColumn('username', 'string', 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
$this->hasMany('Group as Groups', array('refClass' => 'UserGroup',
|
|
||||||
'local' => 'user_id',
|
|
||||||
'foreign' => 'group_id'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// BaseUserGroup.class.php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class has been auto-generated by the Doctrine ORM Framework
|
|
||||||
*/
|
|
||||||
abstract class BaseUserGroup extends sfDoctrineRecord
|
|
||||||
{
|
|
||||||
|
|
||||||
public function setTableDefinition()
|
|
||||||
{
|
|
||||||
$this->setTableName('user_group');
|
|
||||||
$this->hasColumn('user_id', 'integer', 4, array('primary' => true));
|
|
||||||
$this->hasColumn('group_id', 'integer', 4, array('primary' => true));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
$this->hasOne('User', array('local' => 'user_id',
|
|
||||||
'foreign' => 'id'));
|
|
||||||
$this->hasOne('Group', array('local' => 'group_id',
|
|
||||||
'foreign' => 'id'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</code>
|
|
||||||
|
|
||||||
++ Indexes
|
++ Indexes
|
||||||
|
|
||||||
Please see chapter [doc basic-schema-mapping :index :name] for more information about indexes and their options.
|
Please see chapter [doc basic-schema-mapping :index :name] for more information about indexes and their options.
|
||||||
@ -200,11 +271,18 @@ schema.yml
|
|||||||
<code type="yml">
|
<code type="yml">
|
||||||
---
|
---
|
||||||
UserProfile:
|
UserProfile:
|
||||||
tableName: user_profile
|
|
||||||
columns:
|
columns:
|
||||||
user_id: { type: integer, length: 4, primary: true, autoincrement: true }
|
user_id:
|
||||||
first_name: { type: string, length: 20 }
|
type: integer
|
||||||
last_name: { type: string, length: 20 }
|
length: 4
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
|
first_name:
|
||||||
|
type: string
|
||||||
|
length: 20
|
||||||
|
last_name:
|
||||||
|
type: string
|
||||||
|
length: 20
|
||||||
indexes:
|
indexes:
|
||||||
name_index:
|
name_index:
|
||||||
fields:
|
fields:
|
||||||
|
@ -1,19 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once('generated/BaseContact.class.php');
|
require_once('generated/BaseContact.class.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class has been auto-generated by the Doctrine ORM Framework
|
* This class has been auto-generated by the Doctrine ORM Framework
|
||||||
*/
|
*/
|
||||||
class Contact extends BaseContact
|
class Contact extends BaseContact
|
||||||
{
|
{
|
||||||
|
|
||||||
public function setTableDefinition()
|
|
||||||
{
|
|
||||||
parent::setTableDefinition();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once('generated/BaseUser.class.php');
|
require_once('generated/BaseUser.class.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class has been auto-generated by the Doctrine ORM Framework
|
* This class has been auto-generated by the Doctrine ORM Framework
|
||||||
*/
|
*/
|
||||||
@ -7,4 +8,5 @@ class User extends BaseUser
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -9,13 +9,24 @@ abstract class BaseContact extends Doctrine_Record
|
|||||||
public function setTableDefinition()
|
public function setTableDefinition()
|
||||||
{
|
{
|
||||||
$this->setTableName('contact');
|
$this->setTableName('contact');
|
||||||
|
$this->hasColumn('id', 'integer', 11, array('primary' => true,
|
||||||
|
'autoincrement' => true));
|
||||||
$this->hasColumn('name', 'string', 255);
|
$this->hasColumn('name', 'string', 255);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->hasMany('User', array('local' => 'id',
|
$this->hasOne('Adult', array('local' => 'id',
|
||||||
'foreign' => 'contact_id'));
|
'foreign' => 'contact_id'));
|
||||||
|
|
||||||
|
$this->hasOne('User', array('local' => 'id',
|
||||||
|
'foreign' => 'contact_id'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,20 +3,49 @@
|
|||||||
/**
|
/**
|
||||||
* This class has been auto-generated by the Doctrine ORM Framework
|
* This class has been auto-generated by the Doctrine ORM Framework
|
||||||
*/
|
*/
|
||||||
abstract class BaseUser extends Doctrine_Record
|
abstract class BaseUser extends Entity
|
||||||
{
|
{
|
||||||
|
|
||||||
public function setTableDefinition()
|
public function setTableDefinition()
|
||||||
{
|
{
|
||||||
$this->setTableName('user');
|
$this->setTableName('user');
|
||||||
|
$this->hasColumn('id', 'integer', 11, array('primary' => true,
|
||||||
|
'autoincrement' => true));
|
||||||
|
|
||||||
$this->hasColumn('username', 'string', 255);
|
$this->hasColumn('username', 'string', 255);
|
||||||
|
|
||||||
|
$this->hasColumn('hair_color', 'string', 255);
|
||||||
$this->hasColumn('contact_id', 'integer', 11);
|
$this->hasColumn('contact_id', 'integer', 11);
|
||||||
|
|
||||||
|
$this->index('name_x', array('fields' => array('username' => array( 'sorting' => 'ASC', 'length' => '11', 'primary' => true, ), ), 'type' => 'unique'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->hasOne('Contact', array('local' => 'contact_id',
|
$this->hasOne('Contact', array('local' => 'contact_id',
|
||||||
'foreign' => 'id'));
|
'foreign' => 'id'));
|
||||||
|
|
||||||
|
$this->hasMany('Car as Cars', array('refClass' => 'UserCar',
|
||||||
|
'local' => 'user_id',
|
||||||
|
'foreign' => 'car_id'));
|
||||||
|
|
||||||
|
$this->hasMany('Group as Groups', array('refClass' => 'UserGroup',
|
||||||
|
'local' => 'user_id',
|
||||||
|
'foreign' => 'group_id'));
|
||||||
|
|
||||||
|
$this->hasOne('Dog', array('local' => 'id',
|
||||||
|
'foreign' => 'user_id'));
|
||||||
|
|
||||||
|
$this->hasMany('SelfReference as SelfReference1', array('local' => 'id',
|
||||||
|
'foreign' => 'user_id1'));
|
||||||
|
|
||||||
|
$this->hasMany('SelfReference as SelfReference2', array('local' => 'id',
|
||||||
|
'foreign' => 'user_id2'));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,11 @@
|
|||||||
---
|
---
|
||||||
Contact:
|
Contact:
|
||||||
columns:
|
columns:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
length: 11
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
length: 255
|
length: 255
|
@ -1,9 +1,19 @@
|
|||||||
---
|
---
|
||||||
User:
|
User:
|
||||||
columns:
|
inheritance:
|
||||||
|
extends: Entity
|
||||||
|
fields:
|
||||||
|
id:
|
||||||
|
type: integer
|
||||||
|
size: 11
|
||||||
|
primary: true
|
||||||
|
autoincrement: true
|
||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
length: 255
|
length: 255
|
||||||
|
hair_color:
|
||||||
|
type: string
|
||||||
|
length: 255
|
||||||
contact_id:
|
contact_id:
|
||||||
type: integer
|
type: integer
|
||||||
length: 11
|
length: 11
|
||||||
@ -11,3 +21,18 @@ User:
|
|||||||
Contact:
|
Contact:
|
||||||
local: contact_id
|
local: contact_id
|
||||||
foreign: id
|
foreign: id
|
||||||
|
foreignType: one
|
||||||
|
Cars:
|
||||||
|
class: Car
|
||||||
|
refClass: UserCar
|
||||||
|
Groups:
|
||||||
|
class: Group
|
||||||
|
refClass: UserGroup
|
||||||
|
indexes:
|
||||||
|
name_x:
|
||||||
|
columns:
|
||||||
|
username:
|
||||||
|
sorting: ASC
|
||||||
|
length: 11
|
||||||
|
primary: true
|
||||||
|
type: unique
|
Loading…
x
Reference in New Issue
Block a user