Tag:
columns:
name:
type: string(100)
TagNews:
columns:
tag_id:
type: integer
primary: true
news_id:
type: integer
primary: true
relations:
Tag: { onDelete: CASCADE, local: tag_id, foreign: id }
News: { onDelete: CASCADE, local: news_id, foreign: id }
News:
columns:
tag_id:
type: integer
name:
type: string(100)
relations:
Tag:
class: Tag
refClass: TagNews
local: news_id
foreign: tag_id
foreignAlias: TagNews
TAG:
| id | name |
| 1 | tag1 |
| 2 | tag2 |
| 3 | tag3 |
TagNews:
| id_tag开发者_JS百科 | tag_news |
| 1 | 1 |
| 2 | 1 |
| 2 | 2 |
| 3 | 2 |
| 3 | 3 |
| 1 | 3 |
News:
| id | name |
| 1 | news1 |
| 2 | news2 |
| 3 | news3 |
| 4 | news4 |
| 5 | news5 |
how can i get all news for tag1 etc?
for example site.com/tag/tag1 ? what i must write in action.class and template? i use Symfony 1.4 and Doctrine 1.2
$tag = TagTable::getInstance()->find(1);
$news = $tag->getNews();
should work.. otherwise you'll have to define the relation to news in the tag (same as tag in news)
精彩评论