I have all the models. I need to define relation in doctrine and build a query using doctrine.
Query without doctrine which works fine.
SELECT * FROM asset_site_link l
join assets a on l.assetID = a.id
join assetTypes t on t.id = a.assetTypeID
join assetCategories c on c.id = a.categoryID
where t.name="image" AND c.name = "static_banner"
and l.siteID = "2"
My First Attept is something like this, which did not work.
$q = Doctrine_Query::create()
->select('r.*')
->from('assetManagement_Model_asset r')
->leftJoin('r.assetTypeID t')
->leftJoin('r.categoryID c')
->leftJoin('r.assetSiteLink l')
->where('r.isDeleted = 0')
->andWhere('t.name = ?', "image")
->andWhere('c.name = ?', "static_banner")
->andWhere ('l.siteID = ?', "2");
while below query is working fine (without assetSiteLink join)
$q = Doctrine_Query::create()
->select('r.*')
->from('assetManagement_Model_asset r')
->leftJoin('r.assetTypeID t')
->leftJoin('r.categoryID c')
->where('r.isDeleted = 0')
->andWhere('t.name = ?', "image")
->andWhere('c.name = ?', "static_banner");
Just to tell you that Asset model has one to Many Relation with AssetSiteLink
Any Idea?
1 Answer