Results 1 to 10 of 10

Thread: Good database class?

  1. #1

    Thread Starter
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527

    Good database class?

    Does anyone have a link to a good mysql database class or can point me in the right direction and make some suggestions

    thanks

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    What is a MySQL database class?
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,333
    it is a class that connects and queries and all that other stuff. I use the vbullitens free version's db class. does really well for what I need. but it shouldn't be hard to write your own or head over to www.hotscripts.com and find one there. or www.zend.com has pleny of code snippets of the sort.

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I still don't understand. But okay.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,333
    that is because you are still thinking in that box, just kidding

    a db class that I think he is talking about is like this. you know what a class is right? well this class does all the connection stuff to the db. all you have to do in your script is connect to this class and do regular stuff.

    so lets say I have a db class.

    PHP Code:
    class DB_BIG {
      var 
    $Host;      // Hostname of our MySQL server.
      
    var $Database;  // Logical database name on that server.
      
    var $User;     // User and Password for login.
      
    var $Password;

      var 
    $Link_ID    0;  // Result of mysql_connect().
      
    var $Query_ID 0;  // Result of most recent mysql_query().
      
    var $record    = array();  // current mysql_fetch_array()-result.
      
    var $Row;          // current row number.

      
    var $errno    0;  // error state of query...
      
    var $errdesc      "";
      var 
    $appshortname SITE_NAME;
      var 
    $reporterror 1;

      function 
    connect() {
                
            
    $this->Host    HOSTNAME;
            
    $this->User    USER;
            
    $this->Password PASS;
            
    $this->Database DBNAME;

        if ( 
    == $this->Link_ID ) {
          
    $this->Link_ID=@mysql_connect($this->Host$this->User$this->Password);
          if (!
    $this->Link_ID) {
        
    $this->halt("Link-ID == false, connect failed");
          }
          if (!
    mysql_query(sprintf("use %s",$this->Database),$this->Link_ID)) {
        
    $this->halt("Cannot connect to database ".$this->Database);
          }
        }
      }


      function 
    query($Query_String) {
           
    // do query   
        
    $this->Query_ID = @mysql_query($Query_String,$this->Link_ID);
        if (!
    $this->Query_ID) {
          
    $this->halt("Invalid SQL: ".$Query_String);
        }
        return 
    $this->Query_ID;
      } 
    that is a short version of vbullitens free version.

    so in my script I use it like so,

    $db_addCobrand = new DB_BIG; // start a instance of the class
    $db_addCobrand->connect(); // connect to the db
    $db_addCobrand->query("select * from table"); // run my query

    that is a db class in a nut shell.

    do you get it now? all it is is a class that handles all the connections to the db.

  6. #6
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Originally posted by phpman
    do you get it now? all it is is a class that handles all the connections to the db.
    Ah, I see how that could be useful.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  7. #7

    Thread Starter
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    hmm the vbulletin lite db class?

    i was thinking of writing a forum, do either of you want in or will i attempt this voyage solo

  8. #8
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,333
    why another forum? hobo started one not sure if he is still doing it, I can't alocate the time as another project is in my bag. in my opinion there are too many out there as it is. but good luck

  9. #9
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I started developing my own forum, but lost interest in working on it.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  10. #10

    Thread Starter
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    Originally posted by phpman
    why another forum? hobo started one not sure if he is still doing it, I can't alocate the time as another project is in my bag. in my opinion there are too many out there as it is. but good luck
    i want to make an awesome free forum that will rival vbb

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width