我希望我的实体名称与数据库表名称不同(表名具有我不想要的实体前缀。这是我无法控制的。它是现有的大数据库)。
例如,表名是ab_product,我需要实体名称只是Product,而不是AbProduct。
为了使事情变得复杂,我有很少的相关表格都满足这个要求(ab_order,ab_order_product等)。
在Symfony 1中,我曾经在YAML文件中定义所有这些映射和关系,然后使用一个命令生成所有实体类。
在Symfony 2中是否有类似的命令。我无法在" php app / console doctrine中找到一个:generate"命名空间。
答案 0 :(得分:1)
您可以通过在实体中指定表格键来实现此目的
# src/Acme/StoreBundle/Resources/config/doctrine/Product.orm.yml
Acme\StoreBundle\Entity\Product:
type: entity
table: ab_product <-------- This is what you are looking for
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
name:
type: string
length: 100
price:
type: decimal
scale: 2
description:
type: text
您也可以像这样定义连接列的名称:
manyToOne:
order:
targetEntity: Order
inversedBy: products
joinColumn:
name: ab_order
referencedColumnName: id
您可以在此处找到更多信息:http://symfony.com/fr/doc/current/book/doctrine.html
答案 1 :(得分:1)
有关于此的食谱条目:How to Generate Entities from an Existing Database。
由于您已有地图数据,因此您基本上只需要运行...
<com.actinarium.random.common.CollapsingLogoToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:contentScrim="?attr/colorPrimary"
app:logoViewId="@+id/collapsing_logo"
app:collapsedViewOffset="0dp"
app:expandedViewOffset="-56dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:src="@drawable/random_pattern"
android:scaleType="fitXY"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.75"/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin">
</android.support.v7.widget.Toolbar>
<FrameLayout
android:id="@+id/collapsing_logo"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/random_logo"/>
</FrameLayout>
</com.actinarium.random.common.CollapsingLogoToolbarLayout>
...
。