- Code: Select all
Post:
actAs: { Timestampable: ~ }
columns:
id: { type: integer(4), autoincrement: true, primary: true }
title: { type: string(255), notnull: true }
is_public: { type: boolean, notnull: true, default: 0 }
category_id: { type: integer(4), notnull: true, default: 0 }
subcategory_id: { type: integer(4), notnull: true, default: 0 }
language_id: { type: integer(4), notnull: true }
author_id: { type: integer(4), notnull: true }
content: { type: clob }
relations:
Authors:
class: Writer
onDelete: CASCADE
local: author_id
foreign: id
alias: Authors
Languages:
class: Language
onDelete: CASCADE
local: language_id
foreign: id
alias: Languages
Keywords:
class: Keyword
refClass: PostHasKeyword
local: post_id
foreign: keyword_id
alias: Keywords
Categories:
class: Category
onDelete: CASCADE
local: category_id
foreign: id
alias: Categories
SubCategories:
class: SubCategory
onDelete: CASCADE
local: subcategory_id
foreign: id
alias: Subcategories
PostHasKeyword:
columns:
id: { type: integer(4), autoincrement: true, primary: true }
post_id: { type: integer(4), notnull: true, primary: true }
keyword_id: { type: integer(4), notnull: true, primary: true }
relations:
Post:
local: post_id
foreign: id
Keyword:
local: keyword_id
foreign: id
Keyword:
columns:
id: { type: integer(4), autoincrement: true, primary: true }
keyword: { type: string(255), notnull: true, unique: true }
counter: { type: integer(4), default: 0 }
I am using the following Doctrine query:
- Code: Select all
$q2 = Doctrine_Query::create()
->from(PostHasKeyword c')
->leftJoin('c.Post p')
->where('c.post_id=?',$postId);
Using the "$q2->getSQLQuery()" the generated SQL qouery seems below:
- Code: Select all
SELECT
d.id AS d__id,
d.post_id AS d__post_id,
d.keyword_id AS d__keyword_id,
d2.id AS d2__id,
d2.title AS d2__title,
d2.is_public AS d2__is_public,
d2.category_id AS d2__category_id,
d2.subcategory_id AS d2__subcategory_id,
d2.language_id AS d2__language_id,
d2.author_id AS d2__author_id,
d2.content AS d2__content,
d2.created_at AS d2__created_at,
d2.updated_at AS d2__updated_at
FROM
post_has_keyword d
LEFT JOIN
post d2 ON d.post_id = d2.id
WHERE (d.post_id = 1)
If I try the generated query via the phpMyAdmin it works perfect, gives back the expected results however it is look like an empty query when I use it in my PHP code.
How could it be?
Thank ouy in advance.
