Advertisement
Guest User

Untitled

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