Symfony1 当我加入条令时,我在哪里可以修改我的模型来修正这个错误?
我使用的是symfony 1.4和doctrine,目前我在schema.yml上为我的2个表创建了结构,但是当我进行查询时,我得到了这个异常 SQLSTATE[42S22]:未找到列:“on子句”中的1054未知列“o.id”。查询失败:“从ohrm\u传统\u详细信息中选择o.id\u传统\u详细信息作为o\u id\u传统\u详细信息,o.name作为o\u名称,o.type作为o\u类型,o.group作为o\u组从ohrm\u传统\u详细信息中选择o.id上的o.ohrm\u详细信息=o2.ohrm\u传统\u详细信息\u id在哪里(o2.user=4)” 我必须使用表,Symfony1 当我加入条令时,我在哪里可以修改我的模型来修正这个错误?,symfony1,doctrine,symfony-1.4,Symfony1,Doctrine,Symfony 1.4,我使用的是symfony 1.4和doctrine,目前我在schema.yml上为我的2个表创建了结构,但是当我进行查询时,我得到了这个异常 SQLSTATE[42S22]:未找到列:“on子句”中的1054未知列“o.id”。查询失败:“从ohrm\u传统\u详细信息中选择o.id\u传统\u详细信息作为o\u id\u传统\u详细信息,o.name作为o\u名称,o.type作为o\u类型,o.group作为o\u组从ohrm\u传统\u详细信息中选择o.id上的o.ohrm\u详细信息=
details\u info
和adional\u details
,adional details需要在其中一个字段中输入details\u info中的一个条目的id,我不知道这个错误,因为我使用了其他表,但这次我不知道发生了什么
我的schema.yml是这样的
OhrmAditionalDetails:
connection: doctrine
tableName: ohrm_aditional_details
columns:
id_aditional_details:
type: integer(11)
fixed: false
unsigned: false
primary: true
autoincrement: true
name:
type: string(100)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
type:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
group:
type: integer(4)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
OhrmDetailsInfo:
connection: doctrine
tableName: ohrm_details_info
columns:
id_details_info:
type: integer(11)
fixed: false
unsigned: false
primary: true
autoincrement: true
aditional_info:
type: integer(11)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
result:
type: string(200)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
user:
type: integer(11)
fixed: false
unsigned: false
primary: false
notnull: true
autoincrement: false
relations:
OhrmAditionalDetails:
local: aditional_info
foreign: id_aditional_details
type: one
HsHrEmployee:
local: user
foreign: emp_number
type: one
我的问题很简单
try
{
$q = Doctrine_Query::create()
->select('*')
->from('OhrmAditionalDetails D')
->innerJoin('D.OhrmDetailsInfo I')
->where("I.user = $id");
$result = $q->execute();
return $result;
}
catch(Exception $e)
{
print_r ($e->getMessage());
return null;
}
在$id=4的情况下
有什么想法吗?我试过了
php symfony cc
php symfony doctrine:build-model
php symfony orangehrm:publish-assets
php symfony cc
但是没有…它试图猜测要加入的列的名称,例如,查找
id
,而不是id\u传统\u详细信息
看起来您已经在schema.yml中正确地定义了它,但它将其解释为空,因为您没有正确地缩进yaml。尝试:
relations:
OhrmAditionalDetails:
local: aditional_info
foreign: id_aditional_details
type: one
HsHrEmployee:
local: user
foreign: emp_number
type: one
非常感谢。是的,但问题是缩进空间。。。奇怪的东西。“它将其解释为空,因为您没有正确缩进yaml”。缩进在YAML中非常重要。很容易错过他们:)