简体   繁体   English

知道用户何时注册重复链接的最佳方法(MYSQL + PHP)

[英]Best way to know when users register duplicated links (MYSQL + PHP)

so i have a page where a user can submit his own links 所以我有一个页面,用户可以提交自己的链接

i dont want to make a script that do everything automatic, i just want to make a page where, when the .php find a possible duplicated link, i get a warning like "ID 22 could possible have the same link as ID 738" 我不想让脚本自动执行所有操作,我只想创建一个页面,当.php找到可能的重复链接时,我会收到类似“ ID 22可能具有与ID 738相同的链接”的警告。

i only need like the query to do that...if its possible with that..i can only use php and mysql 我只需要像查询那样做...如果可能的话..我只能使用php和mysql

if its too expensive (memory, cpu..) i can make like a submit button then when pressed generates like a report 如果它太贵了(内存,cpu ..),我可以使它像一个提交按钮,然后在按下时生成一个报告

ps: just to be clear, im not showing the message to the user, is something im going to put at my admin cp..and its not comparing "link 1" to "link 2" but searching the entire database thanks ps:为了清楚起见,即时通讯没有向用户显示消息,这是即时通讯要放在我的管理员cp上的原因。它没有将“ link 1”与“ link 2”进行比较,而是搜索整个数据库,谢谢

If you want to know which links are used by more than 1 ID, you could do something like this: 如果您想知道多个ID使用了哪些链接,可以执行以下操作:

SELECT link,COUNT(id)
  FROM link_table
 GROUP BY link
 HAVING COUNT(id) > 1

Your best bet would be to have a query that runs when new links are submitted. 最好的选择是在提交新链接时运行查询。 It could do something like this as a basic example: 作为基本示例,它可以执行以下操作:

SELECT * FROM links WHERE url = "" SELECT * FROM links url =“”

If that returns results, then you have a dupe which can either be prevented from being inserted into the database, or simply flagged somewhere for review. 如果返回结果,则说明您有一个伪造品,可以防止将其插入数据库,也可以将其标记为需要复查的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM