Login   Register  
PHP Classes
elePHPant
Icontem

File: class.LoadData.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jeffrey Hines  >  class.LoadData.php  >  class.LoadData.php  >  Download  
File: class.LoadData.php
Role: ???
Content type: text/plain
Description: Class file
Class: class.LoadData.php
Author: By
Last change:
Date: 2001-01-16 22:04
Size: 1,796 bytes
 

Contents

Class file image Download
<?
/* Author: Jeff Hines 1/14/01 (hinesweb@bellsouth.net)
** Resuable class for loading data into a single MySQL table.
** Constructor parameters LoadData(<tablename>, <databasename>).
** Function parameters InputMember(<Array- table fields>, <Array- fields input>).
 */

require("uservariables.php3");

class LoadData
{
     var $tableName;
     var $databaseName;
  
     /* Begin LoadData Constructor */

     function LoadData( $tblname, $dbname ){
        $this->tableName = $tblname;
        $this->databaseName = $dbname;
     }
     /* End LoadData Constructor */

    
     /* Begin InputMember function */

     function InputMember( $input1, $input2 ){ 
      
      /* Format the first field because of commas */

        $fields = $input1[ 0 ];
        $fieldValues = "'" . $input2[ 0 ] . "'";

      /* End formatting */
      
      /* Format field strings for submission */

      for ($idx = 1; $idx < count($input1); ++$idx) 
      $fields = $fields . ", " . $input1[ $idx ];

      for ($idx = 1; $idx < count($input2); ++$idx) 
      $fieldValues = $fieldValues . ", " . "'" . $input2[ $idx ] . "'";
   
      /* End field String formatting */
 
      /* Connect to database */
       if (!($link = mysql_pconnect ($hostName, $userName, $password))){
           echo("Error connecting to $hostName<BR>");
               exit();
              }

      /* Insert information into database */
      if(!($submitnew = mysql_db_query( $this->databaseName, "INSERT INTO $this->tableName
       ( $fields ) VALUES ( $fieldValues )"))){     
                   
       echo("Error inserting data into $this->databaseName<br>\n");
       exit();
       }

}
/* End Input Member Function */

}
/* End LoadData Class */
?>