Hi,
I am having a problem in symfony doctrine joins. In symfony documentation there is written that if put left or inner joins in query then doctrine doesn't automatically query for that table for example if i have user and profile table
$user = Doctrine::getTable('user')->find($id);
$user->Profile
then doctrine automatically query profile table and fetch related data. but if i use
$users = Doctrine_Query::create()->from(User o')->leftJoin('o.Profile p')->execute();
$user->Profile;
in this case symfony don't query profile table. But in my case symfony is querying related table, i couldn't understand it, i do research for that but no luck. here is my codes.
Site:
actAs: { Timestampable: ~ }
columns:
id: { type: integer, unsigned: true, primary: true, autoincrement: true }
country_id: { type: integer, unsigned: true }
is_default: { type: integer, default: 0 }
icon: { type: string(255) }
relations:
Country: { local: country_id, foreign: id}
Country:
columns:
id: { type: integer, unsigned: true, primary: true, autoincrement: true }
is_default: { type: integer, default: 0 }
enable_selection: { type: integer, default: 0 }
name: { type: string(100), notnull: true, unique: true }
code: { type: string(10), notnull: true }
pay_vat: { type: integer, default: 1 }
icon: { type: string(255) }
and in action my codes are
$site = $this->createQuery('s')->leftJoin('s.Country c')->execute();
and in dev tool bar queryies generating by doctrine is
SELECT s.id AS s__id, s.country_id AS s__country_id, s.is_default AS s__is_default, s.icon AS s__icon, s.created_at AS s__created_at, s.updated_at AS s__updated_at, c.id AS c__id, c.is_default AS c__is_default, c.enable_selection AS c__enable_selection, c.name AS c__name, c.code AS c__code, c.pay_vat AS c__pay_vat, c.icon AS c__icon FROM site s LEFT JOIN country c ON s.country_id = c.id
0.00s, "doctrine" connection
SELECT c.id AS c__id, c.is_default AS c__is_default, c.enable_selection AS c__enable_selection, c.name AS c__name, c.code AS c__code, c.pay_vat AS c__pay_vat, c.icon AS c__icon FROM country c WHERE (c.id = '1') LIMIT 1
0.00s, "doctrine" connection
SELECT c.id AS c__id, c.is_default AS c__is_default, c.enable_selection AS c__enable_selection, c.name AS c__name, c.code AS c__code, c.pay_vat AS c__pay_vat, c.icon AS c__icon FROM country c WHERE (c.id = '1') LIMIT 1
COULDN'T UNDERSTAND WHY DOCTRINE QUERYING BELOW TWO QUERYIES WHILE IT CAN GET DATA FROM FIRST QUERY.
