English 中文(简体)
是否有可能将模式与理论2加以推广?
原标题:Is it possible to extends a Model with Doctrine 2?

情况如下:

父母:

namespace Base;

/** @Entity @Table(name="section") */
class Section extends Skeleton {
/** 
 * @Id @Column(type="integer") 
 * @GeneratedValue(strategy="AUTO")
 */
protected $id;

/** @Column(length=256) */
protected $title;

/** @Column(length=256) */
protected $stylesheet;
}

儿童:

namespace Base2;

use BaseSection AS BaseSection;

/** @Entity @Table(name="tbl_section") */
class Section extends BaseSection {
/**
 * @Id @Column(type="integer")
 * @GeneratedValue(strategy="AUTO")
 */
protected $id;

/** @Column(length=256) */
protected $title;

/** @Column(length=256) */
protected $stylesheet;
}

当我试图从数据库中检索一个科时,就会发现一个错误:

PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column  t0.id  
in  where clause  in /var/www/eage_new_zf/library/Doctrine/DBAL/Connection.php 
on line 567 Call Stack #TimeMemoryFunctionLocation 10.0004489704{main}( 
)../index.php:0 20.03193296632Zend_Controller_Front->dispatch( ???, ??? 
)../index.php:27 30.04574505172Zend_Controller_Dispatcher_Standard->dispatch( 
object(Zend_Controller_Request_Http)[39], object(Zend_Controller_Response_Http)[40] 
)../Front.php:954 Variables in local scope (#3) 

它试图执行的问题是:

SELECT 
    t1.id AS id2, 
    t1.title AS title3, 
    t1.stylesheet AS stylesheet4 
FROM 
    tbl_section t1 
WHERE 
    t0.id = ?

t0在技术上没有定义,这是正确的,我有错误。 但是,如何解决这一问题? 难道这在理论2中是一种 b吗? 或者,我做了一些错误的事情。

最佳回答

您可以使用单一表格,也可以使用单一表格。 差异使用的是一张可取消的栏目表,或根据儿童类别使用许多表格。 见关于烟雾信息的手册:

rel=“nofollow noretinger”>http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/vis/inheritance-mapping.html

在你最高级/最高级职位(基本科)的案例中

/**
 * @Entity @Table(name="section")
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"base" = "BaseSection", "child" = "Base2Section"})
 */

Nam门课是一种坏的做法,你应该把你所领导的班子命名为他们明智的课堂。 即便与已经列入名称的词句相重复,亦即“基地”科和“BAse2Base2”科。

问题回答

暂无回答




相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签