Advertisement
Guest User

Untitled

a guest
Jun 30th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.08 KB | None | 0 0
  1. <?PHP
  2.     Class MySQL
  3.     {
  4.         // Connection of the mysql api
  5.         Private $Connection ;
  6.  
  7.         // Database information
  8.         Private $Hostname ;
  9.         Private $Username ;
  10.         Private $Password ;
  11.         Private $Database ;
  12.  
  13.         // Last handle of query
  14.         Private $HandleOfLastQuery ;
  15.  
  16.         // Methods to set and get the hostname
  17.         Public Function GetHostname ( )
  18.         {
  19.             Return $this->Hostname ;
  20.         }
  21.         Public Function SetHostname ( $Hostname )
  22.         {
  23.             $this->Hostname = $Hostname ;
  24.         }
  25.  
  26.         // Methods to set and get the username
  27.         Public Function GetUsername ( )
  28.         {
  29.             Return $this->Username ;
  30.         }
  31.         Public Function SetUsername ( $Username )
  32.         {
  33.             $this->Username = $Username ;
  34.         }
  35.  
  36.         // Methods to set and get the password
  37.         Public Function GetPassword ( )
  38.         {
  39.             Return $this->Password ;
  40.         }
  41.         Public Function SetPassword ( $Password )
  42.         {
  43.             $this->Password = $Password ;
  44.         }
  45.  
  46.         // Methods to set and get the database
  47.         Public Function GetDatabase ( )
  48.         {
  49.             Return $this->Database ;
  50.         }
  51.         Public Function SetDatabase ( $Database )
  52.         {
  53.             $this->Database = $Database ;
  54.         }
  55.  
  56.         // Method to initialize and connect to the
  57.         // mysql server and database
  58.         Public Function Initialize ( )
  59.         {
  60.             $this->Connection = MySQL_Connect ( $this->Hostname , $this->Username , $this->Password ) ;
  61.             MySQL_Select_DB ( $this->Database , $this->Connection ) ;
  62.         }
  63.  
  64.         // Method to finalize and close the
  65.         // mysql server and database connection
  66.         Public Function Finalize ( )
  67.         {
  68.             MySQL_Close ( $this->Connection ) ;
  69.         }
  70.  
  71.         // Method to send a query to the
  72.         // mysql server and database
  73.         Public Function Query ( $Query )
  74.         {
  75.             $this->HandleOfLastQuery = MySQL_Query ( $Query , $this->Connection ) ;
  76.         }
  77.  
  78.         // Method to fetch an object
  79.         Public Function Fetch ( )
  80.         {
  81.             Return MySQL_Fetch_Object ( $this->HandleOfLastQuery ) ;
  82.         }
  83.  
  84.         // Method to get the row
  85.         Public Function GetRow ( )
  86.         {
  87.             Return $this->HandleOfLastQuery ;
  88.         }
  89.  
  90.         // Method to get the number of rows
  91.         Public Function GetNumberOfRows ( )
  92.         {
  93.             Return MySQL_Num_Rows ( $this->HandleOfLastQuery ) ;
  94.         }
  95.     } ;
  96.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement