Jump to content

cparekh

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by cparekh

  1. Hello all, I was recently introduced to data shaping as a way to manage record-sets and wondered if it can be done in PHP? My google search only brought up this thread at phpbuilder - http://www.phpbuilder.com/board/showthread.php?t=66995 - from way back in 2000, but not much else. Anyone have any experience or knowledge of SHAPE using PHP? Thanks in advance, C.
  2. My worry is that because I have 8 levels I'll end up with a few hundred conditional statements for all the combinations/permutations possible I've just tried writing a statement for each and although I haven't yet met each combination I have over 60 conditional statements - too many to manage effectively I feel. Is there an easier way to iterate through so many possibilities?
  3. Hi, I'm having trouble scaling a script I wrote a while back... background: The script is like a search-able address book. There are 8 access levels and the user can have permission access to a combination of any/all levels. The results returned are based on the access level combination as a sql query is created based on that access level combination i.e. a user can only see other users at their level. There used to be only 3 levels and so I had a block of conditional statements to generate the required sql query. However with 8 levels there would be too many statements to maintain and errors are very likely. I can only think that the best way to do this is to use a multi-dimensional array (?) but I have no idea how to set it up and then traverse it to get the relevant values out to use (I don't have much experience with multi-dimensional arrays). This is what the current code is: //Create the sql conditions for each access level if ($access1 == 'yes') { $sql1 = "usertype= 'Principal' or usertype = 'Principal Assistant' or usertype = 'Named' or usertype = 'E-mail' or usertype = 'Web' "; } if ($access2 == 'yes') { $sql2 = "usertype = 'Principal' or usertype = 'Deputy Principal' or usertype = 'Contact'"; } if ($access3 == 'yes') { $sql3 = "usertype = 'Principal' or usertype = 'Contact' "; } //join them if (($access1 == 'yes') and ($access2 == 'yes') and ($access3 == 'yes')) //all 3 { $sqlconditions = $sql1." or ".$sql2." or ".$sql3; } elseif (($access1 == 'yes') and ($access2 == 'yes') and ($access3 == 'no')) { $sqlconditions = $sql1." or ".$sql2; } elseif (($access1 == 'yes') and ($access2 == 'no') and ($access3 == 'no')) { $sqlconditions = $sql1; } elseif (($access1 == 'no') and ($access2 == 'yes') and ($access3 == 'yes')) { $sqlconditions = $sql2." or ".$sql3; } elseif (($access1 == 'no') and ($access2 == 'yes') and ($access3 == 'no')) { $sqlconditions = $sql2; } elseif (($access1 == 'no') and ($access2 == 'no') and ($access3 == 'yes')) { $sqlconditions = $sql3; } elseif (($access1 == 'yes') and ($access2 == 'no') and ($access3 == 'yes')) { $sqlconditions = $sql1." or ".$sql3; } $sqlconditions is passed into the main sql query as a condition. For each access level we have different user types i.e. 'Principal', 'Contact' etc. (btw, none of user access values or types are held in a local db - they are written into the session when a user logs in after the db of a third party crm is interrogated ) Any help or direction is greatly appreciated. Thanks, C.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.