I don't even know what this is called to search for it
Posted: Wed Jul 21, 2004 5:15 am
I'm going to have to dip straight in with real world examples here. It's a theory issue but I don't know what these systems are called so I'll describe it thusly:
I have an SQL table of solicitors details.
There is a column called work_category which currently has in text things like "Wills & Probate", "Trusts", "Conveyancing" etc.
This table needs to be searched using drop down menus to list these categories. Now I think it would make more sense for extensibility reasons to have the ability to keep track of more than one work category for each solicitor. For a start I'm keeping all the categories in an array so I can deal with simple numbers instead of text as it's a little more secure (sql injection and all that)
So now instead of the column containing text it could contain a "1" for Wills and Trusts, a "2" for Probate etc.
Next thing, I want to have multiple sub categories, but since I want it to be extensible I want to keep using one column.
I could use a text field and put multiple numbers in with a delimeter like 2|4|5, then split on the delimeter and see if the array contains "3" for conveyancing.
Thinking about the unix permission system I thought of using some binary type of coding, so for the above entry (2|4|5) I would enter 010110 instead or perhaps the decimal equivalent "22" could be used.
But what happens if another category is added, or if the category list is dynamic? How do I make this system extensible for any number of categories? And what's this system called so I can do a search on it?
Or is there something simple I'm overlooking?
Having written that all out I'm now inclined towards the delimeter option. If I put a pipe in at the start and end I could just put a regex search in my sql for a pipe followed by the array_key and a further pipe which would be quite simple to do. But would I be missing out some vital new knowledge if I used the permissions type scheme?
Help? Comments? Suggestions?
I have an SQL table of solicitors details.
There is a column called work_category which currently has in text things like "Wills & Probate", "Trusts", "Conveyancing" etc.
This table needs to be searched using drop down menus to list these categories. Now I think it would make more sense for extensibility reasons to have the ability to keep track of more than one work category for each solicitor. For a start I'm keeping all the categories in an array so I can deal with simple numbers instead of text as it's a little more secure (sql injection and all that)
Code: Select all
<?php
$subSectorArray = array("Any"
,"Wills & Trusts"
,"Probate"
,"Conveyancing"
,"Matrimonial"
,"Corporate"
,"Other"
);
?>Next thing, I want to have multiple sub categories, but since I want it to be extensible I want to keep using one column.
I could use a text field and put multiple numbers in with a delimeter like 2|4|5, then split on the delimeter and see if the array contains "3" for conveyancing.
Thinking about the unix permission system I thought of using some binary type of coding, so for the above entry (2|4|5) I would enter 010110 instead or perhaps the decimal equivalent "22" could be used.
But what happens if another category is added, or if the category list is dynamic? How do I make this system extensible for any number of categories? And what's this system called so I can do a search on it?
Or is there something simple I'm overlooking?
Having written that all out I'm now inclined towards the delimeter option. If I put a pipe in at the start and end I could just put a regex search in my sql for a pipe followed by the array_key and a further pipe which would be quite simple to do. But would I be missing out some vital new knowledge if I used the permissions type scheme?
Help? Comments? Suggestions?