Source for file connINC.php

Documentation is available at connINC.php

  1. <?
  2. /**
  3.  * connINC.php creates connection to database
  4.  * 
  5.  * MySQL credentials are stored inside a function named conn()
  6.  *  which allows up to 5 levels of access.
  7.  *  
  8.  * The function conn() returns an active connection to the DB.
  9.  *  
  10.  * @package ITC280
  11.  * @author Bill Newman <williamnewman@gmail.com>
  12.  * @version 1.0 2008/05/03
  13.  * @link http://www.newmanix.com/itc280/
  14.  * @license http://opensource.org/licenses/osl-3.0.php Open Software License ("OSL") v. 3.0
  15.  * @todo none
  16.  */
  17.  
  18. /**
  19.  * Provides active connection to MySQL DB.
  20.  *
  21.  * One of 5 MySQL credentials are passed to the function
  22.  *  as one of the following strings:
  23.  *
  24.  * 1 admin
  25.  * 2 delete
  26.  * 3 insert
  27.  * 4 update
  28.  * 5 select
  29.  *  
  30.  * Each level of access should include the capabilities of those below it.
  31.  * MySQL accounts must be setup for each level, with 'select' account only able
  32.  * to access db via 'select' command, and update able to 'select' and 'update' etc.
  33.  * Each credential set must exist in MySQL before it can be used.
  34.  *
  35.  * The function returns an active connection to the DB.
  36.  *  
  37.  * If no data is entered into conn() function when it is called, the default access is 'admin'.
  38.  *
  39.  * If only one credential is available, place it in the 'admin' position, and no parameter is required.
  40.  *
  41.  *   
  42.  * @param string $access represents level of access
  43.  * @return object Returns active connection to MySQL db.
  44.  * @todo error logging, or emailing admin not implemented
  45.  */ 
  46.  
  47. function conn($access="admin")
  48. {
  49.     switch($access)
  50.     {
  51.         case "admin":    
  52.             $myUserName "horsey01"//your Zephir username
  53.             $myPassword "xxxxxx"//your MySQL password    
  54.             break;
  55.         case "delete":    
  56.             $myUserName "horsey01"
  57.             $myPassword "xxxxxx"
  58.             break;    
  59.         case "insert":    
  60.             $myUserName "horsey01"
  61.             $myPassword "xxxxxx"
  62.             break;
  63.         case "update":    
  64.             $myUserName "horsey01"
  65.             $myPassword "xxxxxx"
  66.             break;
  67.         case "select":    
  68.             $myUserName "horsey01"
  69.             $myPassword "xxxxxx"
  70.             break;        
  71.         
  72.     }
  73.     $myHostName "localhost";  
  74.     $myConn @mysql_connect($myHostName,$myUserName,$myPasswordor die(myerror(__FILE__,__LINE__,mysql_error()));
  75.     return $myConn;
  76. }
  77. ?>

Documentation generated on Sat, 03 May 2008 19:47:45 -0700 by phpDocumentor 1.4.1