[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/attributeManager/classes/ -> amDB.class.php (source)

   1  <?php
   2  /*
   3    $Id: DB.class.php,v 1.0 21/02/06 Sam West$
   4  
   5    osCommerce, Open Source E-Commerce Solutions
   6    http://www.oscommerce.com
   7  
   8    Released under the GNU General Public License
   9    
  10    Copyright  2006 Kangaroo Partners
  11    http://kangaroopartners.com
  12    [email protected]
  13  */
  14  
  15  /**
  16   * OSC Database functions wrapper - just in case they decide to release ms3 the moment i release this - he he
  17   */
  18  class amDB {
  19      
  20      /**
  21       * @author Sam West aka Nimmit - [email protected]
  22       * @package $strQuery sting - sql query string
  23       * @return query reference
  24       */
  25  	function query($strQuery) {
  26          return tep_db_query($strQuery);
  27      }
  28      
  29      /**
  30       * Fetches the next array from a mysql query reference
  31       * @author Sam West aka Nimmit - [email protected]
  32       * @param $ref - referece from a mysql query
  33       * @return array
  34       */
  35  	function fetchArray($ref) {
  36          return tep_db_fetch_array($ref);
  37      }
  38      
  39      /**
  40       * Gets the field count from a mysql query reference
  41       * @author Tomasz Iwanow aka TomaszBG - [email protected]
  42       * @param $ref - referece from a mysql query
  43       * @return int - number of fields in result
  44       */
  45  	function numFields($ref) {
  46          return mysql_num_fields($ref);
  47      }
  48      
  49      /**
  50       * Gets the field name from a mysql query reference
  51       * @author Tomasz Iwanow aka TomaszBG - [email protected]
  52       * @param $ref - referece from a mysql query
  53       * @param $offset - offset of a field
  54       * @return string - name of the field
  55       */
  56  	function fieldName($ref,$offset) {
  57          return mysql_field_name($ref,$offset);
  58      }
  59      
  60      /**
  61       * Counts the number of results from a mysql query referece
  62       * @author Sam West aka Nimmit - [email protected]
  63       * @param $ref - reference from a mysql query
  64       * @return int - number of rows in result
  65       */
  66  	function numRows($ref) {
  67          return tep_db_num_rows($ref);
  68      }
  69      
  70      /**
  71       * peforms inserts / updates
  72       * @author Sam West aka Nimmit - [email protected]
  73       * @param $strTable string tablename
  74       * @param $arrData array data to be inserted/ updated
  75       * @param $strAction sting - update / insert
  76       * @param $strParams string additonal where clauses
  77       * @return void
  78       */
  79  	function perform($strTable,$arrData,$strAction='insert',$strParams='') {
  80          return tep_db_perform($strTable,$arrData,$strAction,$strParams);
  81      }
  82      
  83      /**
  84       * Returns a singular result from a mysql query
  85       * @param $strQuery string - mysql query
  86       * @return mixed - first record, first row
  87       */
  88  	function getOne($strQuery) {
  89          $res = amDB::query($strQuery);
  90          if ($res && amDB::numRows($res)) 
  91              return mysql_result($res,0,0);
  92          return false;
  93      }
  94      
  95      /**
  96       * Returns all results from a mysql query
  97       * @author Sam West aka Nimmit - [email protected]
  98       * @param $strQuery string - mysql query
  99       * @return array - all results
 100       */
 101  	function getAll($strQuery) {
 102          $res = amDB::query($strQuery);
 103          $results = array();
 104          while($row = amDB::fetchArray($res))
 105              $results[] = $row;
 106          return $results;
 107      }
 108      
 109      /**
 110       * Prepares string for database input
 111       * @author Sam West aka Nimmit - [email protected]
 112       * @param $str string 
 113       * @return void
 114       */
 115  	function input($str) {
 116          return tep_db_prepare_input($str);
 117      }
 118      
 119      /**
 120       * Returns placebo autoincrement value
 121       * @access public
 122       * @param $strTable string table name
 123       * @param $strField string field name
 124       * @return mixed
 125       */
 126  	function getNextAutoValue($strTable,$strField) {
 127          return (int)amDB::getOne("select max($strField) + 1 as next from $strTable limit 1");
 128      }
 129      /**
 130       * Some contributions such as the Ultimate SEO URLs have there own 
 131       * database functions. This can cause the internal, last insert id to be 
 132       * wrong if the link id isn't included in the mysql_insert_id statement.
 133       * For this reason i have not used the default osc function for this one as for some
 134       * reason they haven't put the link in their wrapper function.
 135       * @author Sam West aka Nimmit - [email protected]
 136       * @param $link sting - db link name
 137       * @return void
 138       */
 139  	function insertId($link = 'db_link' ) {
 140          global $$link;
 141          return mysql_insert_id($$link);
 142      }
 143  }
 144  
 145  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7