I'm using Doctrine 1.2 with Symfony 1.4. Let's say I have a User model, which has one Profile. These are defined as:
User:
- id
- username
- password
- created_at
- updated_at
Profile:
- id
- user_id
- first_name
- last_name
- address
- city
- postal_code
I would normally get data like this:
$query = Doctrine_Query::create()
->select('u.id, u.username, p.first_name, p.last_name')
->from('User u')
->leftJoin('Profile p')
->where('u.username = ?', $username);
$result = $query->fetchOne(array(), Doctrine_Core::HYDRATE_ARRAY);
print_r($result);
This would output something like the following:
Array (
"User" => Array (
"id" => 1,
"username" => "jschmoe"
),
"Profile" => Array (
"first_name" => "Joseph",
"last_name" => "Schmoe"
)
)
However, I would like for user to include "virtual" columns (not sure if this is the right term) such that fields from Profile actually look like they're a part of User. In other words, I'd like to see the print_r statement look more like:
Array (
"User" => Array (
"id" => 1,
"username" => "jschmoe",
"first_name" => "Joseph",
"last_name" => "Schmoe"
)
)
Is there a way to do this either via my schema.yml file or via my Doctrine_Query object?