English 中文(简体)
继承和保修
原标题:Symfony project inheritance and sfguard

难道这是我的Schema的右yn吗?

  user_type_1 :
    inheritance:
    type:             concrete
    extends:          sfGuardUser
 columns:
   name: { type: string(255) }

  user_type_2 :
    inheritance:
    type:             concrete
    extends:          sfGuardUser
 columns:
   name: { type: string(255) }

我的项目由两类使用者组成:user_type_1user_type_2,并且希望两人从FGuardUser 继承,shoud i 即使用继承类型concretecolumn_aggregation

thx

最佳回答

You can use either one, it depends on what you want. From the docs:

Concrete
Concrete inheritance creates separate tables for child classes. However in concrete inheritance each class generates a table which contains all columns (including inherited columns). In order to use concrete inheritance you’ll need to add explicit parent::setTableDefinition() calls to child classes as shown below.

Column Aggregation
In the following example we have one database table called entity. Users and groups are both entities and they share the same database table. The entity table has a column called type which tells whether an entity is a group or a user. Then we decide that users are type 1 and groups type 2. The only thing we have to do is to create 3 records (the same as before) and add the call to the Doctrine_Table::setSubclasses() method from the parent class.

使用具体的继承法将设立2个表格(用户_类型1和用户_类型_2)。

问题回答

暂无回答




相关问题
Doctrine quoting apostrophes

I am using Doctrine ORM for php and Zend MVC. I have a mysql database. When I insert into the database it is escaping quotes. In other-words when I enter <input name="customer_name" value="Test ...

What does mutators and accessors do in Doctrine?

In this document, it explains how to use mutators and accessors in Doctrine, but does not explain what they are. Could anyone explain what mutators and accessors do and what they are? Thanks in ...

Tracking the views of a given row

I have a site where the users can view quite a large number of posts. Every time this is done I run a query similar to UPDATE table SET views=views+1 WHERE id = ?. However, there are a number of ...

Doctrine schema.yml generator

I am pretty new to doctrine. I made two small projects with doctrine for my own but now I am about to create big project for my client. The project will have more than 50 tables. Is there any way of ...

How does Doctrine handle changes to the database schema?

In brief, what happens when you add a column to a table? What happens when you remove one? In more details, suppose you have the following: class User extends Doctrine_Record { public function ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签