Reputation: 5858
I am using symfony 1.4 and doctrine, I currently created the structure on the schema.yml for my 2 tables, but when I make the query I get this exception
SQLSTATE[42S22]: Column not found: 1054 Unknown column 'o.id' in 'on clause'. Failing Query: "SELECT o.id_aditional_details AS o__id_aditional_details, o.name AS o_name, o.type AS o_type, o.group AS o__group FROM ohrm_aditional_details o INNER JOIN ohrm_details_info o2 ON o.id = o2.ohrm_aditional_details_id WHERE (o2.user = 4)"
I have to tables, details_info
and aditional_details
, aditional details requires in one of the fields the id of one entry in details_info , I dont know this error because Ive done it with other tables, but this time I have no idea whats going on...
My schema.yml is like this
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
and my query, quite simple
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;
}
in the case $id = 4
Any idea? Ive tried
php symfony cc
php symfony doctrine:build-model
php symfony orangehrm:publish-assets
php symfony cc
but nothing...
Upvotes: 0
Views: 115
Reputation: 2893
It's trying to guess the name of the column to join on, e.g. looking for id
instead of id_aditional_details
.
It looks like you have defined it properly in your schema.yml, but it's interpreting it as empty because you haven't indented your yaml properly. Try:
relations:
OhrmAditionalDetails:
local: aditional_info
foreign: id_aditional_details
type: one
HsHrEmployee:
local: user
foreign: emp_number
type: one
Upvotes: 2