Want help with php mysql class

Started on the old forum in November 2010 · view the original in the archive · old links redirect here

1 reply · 322 views · started 16 years ago · 1 min read

2 participants
antony2kx Developer · 94 posts #1

I am tring to get this class to work it displays no errors but it also isn't getting any records from the database

<?php

#this script is a part of downloadcity
#Must not be used for anything else

class database
{
    private $dbhost;
    private $dbuser;
    private $dbpass;
    private $dbname;

     function __construct($dbhost, $dbuser, $dbpass, $dbname)
     {

          $this->dbname = $dbname;
          $this->dbuser = $dbuser;   
          $this->dbpass = $dbpass;
          $this->dbhost = $dbhost;

     }

     protected function __connect()
     {
          return @mysql_connect($this->dbhost, $this->dbuser, $this->dbpass);

     }

     protected function __connectDatabase()
     {
          return @mysql_select_db($this->dbname, database::__connect);
     }

     public static function getAll($table="")
     {
          return @mysql_query("SELECT * FROM ".$table."", database::__connectDatabase);
     }

     
     public static function getUnique($table="", $idField, $id)
     {
          return @mysql_query("SELECT * FROM ".$table." WHERE ".$idField."='{$id}'", database::__connectDatabase);
     } 
          
     public static function getAllOrderBy($table="", $orderField, $orderMethod)
     {
          return @mysql_query("SELECT * FROM ".$table." ORDER BY ".$orderField." ".$orderMethod."", database::__connectDatabase);
     }

     public static function getBySql($sql="")
     {
          return @mysql_query($sql, database::__connectDatabase);
     }

     public static function killConnection()
     {
       return @mysql_close(database::__connectDatabase);
     }

     

} 
#end class to handle mysql connection        

  

?>   
     

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close