List:General Discussion« Previous MessageNext Message »
From:Benjamin Pflugmann Date:February 24 2000 11:45pm
Subject:Re: Blacklist
View as plain text  
Hi.

I have once made something similar (I have changed it a bit so you
might have to correct typos before it works):

CREATE TABLE blacklist (
  id int(11) DEFAULT '0' NOT NULL auto_increment,
  reason enum('BL_REQUEST','BL_BAN','BL_TYPO') DEFAULT 'BL_REQUEST' NOT NULL,
  pattern varchar(255) DEFAULT '' NOT NULL,
  last_changed timestamp(14),
  made timestamp(14),
  comment varchar(255) DEFAULT '' NOT NULL,
  PRIMARY KEY (id)
);

(you have to figure out yourself, what 'reasons' may apply for your
case)

To ban all 0800* numbers, you have to do

INSERT INTO blacklist (reason, pattern, comment)
VALUES ('BL_BAN','0800%','don\'t allow such stuff :-)');

To test for banned numbers you would do (assuming that you want to
test the number '555-12345' for validity)

SELECT id, reason, comment
FROM   blacklist
WHERE  '555-12345' LIKE pattern

Note the order of the phone number and the pattern. If you prefer
regular expressions, you would do instead

INSERT INTO blacklist (reason, pattern, comment)
VALUES ('BL_BAN','0800.*','don\'t allow such stuff :-)');

SELECT id, reason, comment
FROM   blacklist
WHERE  '555-12345' REGEXP pattern

Use whatever you like more. LIKE is more portable between SQL server
than REGEXP.

Bye,

        Benjamin.

On Thu, Feb 17, 2000 at 03:48:38PM +0100, pelle@stripped wrote:
> Hi,
> 
> I want to create a table that holds phonenumbers that are blacklisted.
> And then check a number against this table to see if it blacklisted or not.
> The problem I have is that I want to add entries with wildcards.
> 
> e.g. 0800* should match all numbers starting with 0800.
> 
> How do i INSERT this rows and how do I write the SELECT
Thread
BlacklistPelle Eliasson17 Feb
  • RE: BlacklistGordon Bissell17 Feb
  • Re: BlacklistBenjamin Pflugmann25 Feb
RE: BlacklistJames Gray17 Feb
  • Re: BlacklistFaisal Nasim17 Feb
    • Re: BlacklistMatthias Urlichs17 Feb