Go Back   Novahq.net Forum > Computers > Web design and Programming
FAQ Community Calendar Today's Posts Search

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-28-2005, 12:28 AM
JonM is offline JonM
Registered User

Join Date: Jun 2004
Posts: 2,156

Easy MySqL class

learned this from one of p's scripts so you know it's good, anyways i'm using it so now u know it's REALLY good... haha jk any ways:

PHP Code:
class site_Template {
    var 
$userdata = array();
    var 
$db;
    var 
$site = array();
    var 
$mysqldata = array();
    var 
$key;
    var 
$page;
    
##################  MySQL Stuff Before we go through with the site  ##################
    
function connect($host$m_user$m_pass$m_db$m_per){
        
$this->mysqldata['host'] = $host;
        
$this->mysqldata['username'] = $m_user;
        
$this->mysqldata['password'] = $m_pass;
        
$this->mysqldata['db'] = $m_db;
        
$this->mysqldata['persistency'] = $m_per;
        if(
$this->mysqldata['persistency']){
            
$this->mysqldata['connect'] = @mysql_pconnect($this->mysqldata['host'],$this->mysqldata['username'],$this->mysqldata['password']);
        } else {
            
$this->mysqldata['connect'] = @mysql_connect($this->mysqldata['host'],$this->mysqldata['username'],$this->mysqldata['password']);
        }
        if((
$this->mysqldata['connect']) AND ($this->mysqldata['db'])){
            if(@
mysql_select_db($mysqldata['db'],$mysqldata['connect'])){
                return 
true;
            } else {
                return 
false;
            }
        }
        return 
false;
    }
    
    function 
fetch($query=""){
        
$query = @mysql_fetch_array($query);
        return(
$query);
    }
    
    function 
query($query="",$sup=""){
        if(
$sup){
            
$query = @mysql_query($query,$this->mysqldata['connect']);
        } else {
            
$query = @mysql_query($query,$this->mysqldata['connect']) or die("<b>Debug</b>".mysql_error()."<b>");
        }
        return(
$query);
    }
    
    function 
rows($query=""){
        
$query = @mysql_num_rows($query);
        return(
$query);
    }
    
    function 
free($query=""){
        @
mysql_free_result($query);
    }
    
    function 
result($query=""$sup=""){
        
$query $this->query($query,$sup);
        
$result $this->fetch($query,$sup);
        
$this->free($query);
        return(
$result);
    }
    
    function 
getrows($query=""$sup=""){
        
$query $this->query($query,$sup);
        
$rows $this->rows($query);
        
$this->free($query);
        return(
$result);
    }
    
    function 
disconnect() {
        @
mysql_close($this->mysqldata['connect']);
    }

of course i made my changes but o welll... anyways enjoy! O yeah , hta'ts not even close to the 1/4 th of my full class for my site i'm working hard
Reply With Quote
  #2  
Old 05-28-2005, 09:45 AM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
that is how I am learning.

I am looking at the queries from Simple Squad site and his upload script
__________________
Reply With Quote
  #3  
Old 05-28-2005, 09:48 AM
IcIshoot is offline IcIshoot

Join Date: Mar 2004
Location: Farmington Hills, MI
Posts: 1,473

Send a message via AIM to IcIshoot Send a message via MSN to IcIshoot Send a message via Yahoo to IcIshoot
Personally, I like the mysql class that comes with phpnuke.

Real simple.

Plus it has a few more information gathering functions,

I would post it but it is 300+ lines long.

Last edited by IcIshoot; 05-28-2005 at 09:59 AM.
Reply With Quote
  #4  
Old 05-28-2005, 11:29 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,922

it is a really simple class, i use it because it saves mucho time.. you can also make it to filter / log false querys, like I do here on novahq... that way you can use the class to protect, and silently log mysql errors..
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Class Project EDGE Sigs and Graphics 7 05-29-2007 09:13 AM
Class Camp Chrispy General Chat 9 11-25-2006 06:52 PM
First Class Blonde bigsmellyfart Humor & Jokes 5 10-12-2006 09:08 PM
ediquette class Dragon-SC- Humor & Jokes 4 10-22-2005 04:17 PM


All times are GMT -5. The time now is 12:51 PM.




Powered by vBulletin®