我是新手mysql
。
我想为我的博客开发一个简单的标记系统,并遇到了制作 3 个表格的“毒药”解决方案。
所以,我有3张桌子:
`blog` containing `id` and `title`.
`blog_tags` containing `id` and `tags_id` and `blog_id`.
`tags` containing `id` and `name`.
tags_id
连接到Internal Relation
表中id
。tags
同样,blog_id
连接到Internal Relation
表中id
。blog
因此,当在我的函数中(我得到与单个博客有关的所有标签的数组)时,我执行一个查询(例如,将博客id
作为函数中的参数传递),
$result = mysql_query("SELECT tags_id FROM blog_tags WHERE blog_id = '".$id."'");
$tags = array();
if($result === FALSE) {
die(mysql_error()); // TODO: better error handling
}
while($row = mysql_fetch_assoc($result)) {
$tags[] = I don't know what should come over here?
}
return $tags;
或者有没有其他方法可以在这个 Toxi 实现中执行查询?