SQL
$rs = $do->query(
"SELECT
t.name as name,
tr.object_id as object_id
FROM wp_terms as t
JOIN wp_term_relationships as tr ON tr.term_taxonomy_id = t.term_id
JOIN blog as b ON b.url = tr.object_id "
);
UPDATE
while ($r = mysqli_fetch_array($rs)){
$key = "";
$key .= $r["name"];
$do->query(
"UPDATE `blog` SET
`tags` = "{$key}"
WHERE url = "{$r["object_id"]}" "
);
}
according to t
and tr
, use tr.object_id
to t
to find the corresponding t.name
Database structure:
object_id / name
is that I update to the tags
field of the number table blog
and use ,
separation.
and tr.object_id
also means b.url
blog
as b
url / tags
for example, in this blog, post of 13421, I want to add all his name to b.tags
, using ,
to separate
but the problem that arises now is that forever is the last one to be updated into b.tags!
suppose this blog finds a b.tags,
, the only time you enter b.tags is e,
what"s going on?