You are not logged in.
Pages: 1
Hi!
Can you please help? I would like to write a query. But the doctrine will generate incorrect code, and I do not understand why.
#schema.yml:
Car:
connection: doctrine
tableName: car
columns:
id:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
brand:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Users:
local: id
foreign: car_id
type: many
class: User
User:
connection: doctrine
tableName: user
columns:
id:
type: integer(8)
fixed: false
unsigned: false
primary: true
autoincrement: true
name:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
email:
type: string()
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
phone:
type: string(9)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
car_id:
type: integer(8)
fixed: false
unsigned: false
primary: false
notnull: false
autoincrement: false
relations:
Car:
local: car_id
foreign: id
type: one#index.phtml
$q = Doctrine_Query::create()
->select('id,brand')
->from('Model_User u')
->leftJoin('Model_Car c');
echo $q->getSqlQuery(); #firefox output
SELECT u.id AS u__id, u.brand AS u__brand FROM user u, car c
// test.php
// ...
$q = Doctrine_Query::create()
->select('u.username, p.*')
->from('User u')
->leftJoin('u.Phonenumbers p')
echo $q->getSqlQuery();the above call to getSql() would output the following SQL query:
SELECT
u.id AS u__id,
u.username AS u__username,
p.id AS p__id,
p.user_id AS p__user_id,
p.phonenumber AS p__phonenumber
FROM user u
LEFT JOIN phonenumber p ON u.id = p.user_id
What could be the reason that I can not generate this type of code?
Offline
try
$q = Doctrine_Query::create()
->select('u.id,u.name,c.*')
->from('Model_User u')
->leftJoin('u.Car c');
echo $q->getSqlQuery();
Offline
Pages: 1