P
P
Peter Zubkov2015-12-10 20:59:48
PHP
Peter Zubkov, 2015-12-10 20:59:48

How to avoid matches in DB and add new data?

I have a posts table with posts. Posts have tags, which are implemented by the tags and posts_tags tables. Posts are added using a parser.
The process looks like this:
1. the parser outputs data to json >
2. the php script turns this data first into an array, and then into ready-made commands for sql >
3. control-contolve sql code in phpmyadmin
An important point, tags can be new, which are not in db. Question: how in this case to check if there is a tag or not? And what are the options?
Addition: there was an idea to check tag_name using LIKE, but suddenly there are some more convenient ways
Posts table structure:

------------------
             posts
------------------
post_id
------------------
post_body
------------------

posts_tags:
------------------
        posts_tags
------------------
post_id
------------------
tag_id
------------------

and tags:
------------------
              tags
------------------
tag_id
------------------
tag_name
------------------

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
c5c5, 2015-12-10
@peterzubkoff

Do you want to check the tag by id or just by the word, for example "health"?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question