"disable" some MySql records so that they do not return when searching?

I have a mysql database that I support using phpMyAdmin.

The website for which the website is intended for ads.

The problem is that whenever a new classification is published (and inserted into the mysql database), I need to view it manually first.

My question is, is there anyway to tell mysql that "this record is inactive, so don't return it"?

I know one-way access to add a column called โ€œstateโ€ and change it to โ€œactiveโ€ for all the ads I want actively. But is there any other method built into mysql that does the same?

In other words, I do not want the record to return when users viewed the website, unless the record was first verified by me.

EDIT:

I know the WHERE clause, this is not my Q. Is there any other method built into phpMyAdmin?

thanks

+4
source share
6 answers

I know the WHERE clause, i.e. not my Q here. Is there any other method built into phpMyAdmin?

no, it is not. you need to use the "state" column to get what you want.

+6
source

There is no built-in method. In addition to the methods mentioned above, you can try using views to filter inactive records. Instead:

SELECT * FROM table WHERE status = 'active'; 

use the view:

 CREATE VIEW only_active AS SELECT * FROM table WHERE status = 'active'; 

and then just

 SELECT * FROM only_active 

This makes you sure that you will never receive inactive records.

+5
source

If you use the ORM Doctrine, you can use the SoftDelete behavior, which does exactly what you want. You can create queries, and "SoftDeleted" records are not returned. You must use Doctrine for this.

If you cannot go with the Doctrine, I would take advantage of the decision of Peter Pankovsky. The only thing I would use is a DateTime field, not a Boolean field. Set the field to the current DateTime when it is added, and NULL when it is not disabled.

+2
source

There are no properties at the row level, other than the ones you specify for yourself. So, the answer is finally no.

Using the representations described by Peter may be helpful to you; especially if you make a difference and

  • rename source table
  • create a name in it that will only return "verified" records

Thus, the solution can be transparent to your application.

A few notes:

  • In the database, it does not matter if phpMyAdmin or any other client / application looks at the data, all clients are essentially equal; therefore, it is understood that what you ask for cannot be possible (otherwise, how would this hiding mechanism determine if it should display lines or hide them?).
  • There is a semi-definition, but RDBMS that supports row-level security can do this (but effectively such a system stores an additional attribute for each row)

EDIT: Forgot the link http://www.sqlmaestro.com/resources/all/row_level_security_mysql/ This gives some examples and details.

+2
source

Enter the reviewed column in the table of type BOOLEAN. Initialize it to false and update to true as soon as the list is viewed. Whenever you get a list of ads for a site, include reviewed=true in the WHERE clause.

There is no path in phpMyAdmin.

+1
source

In fact, there is no way to achieve this without having some kind of DB field that tells you which records you viewed and which didn't.

So the only reasonable answer you get is to โ€œadd a status fieldโ€.

The question is, why don't you want to do this? (especially if you already know how to do this). If you can answer this, you can get helpful help in solving problems that, as you understand it, can give you an obvious answer.

+1
source

All Articles