View Single Post
ישן 18-07-07, 23:41   # 8
phpyo
חבר בקהילה
 
מיני פרופיל
תאריך הצטרפות: Jan 2007
הודעות: 180

phpyo לא מחובר  

PHP קוד:
<?php

/***************************************************************

    Name : classes.php
    Description: Includes several important classes
    
***************************************************************/

    
include("constants.php");


/*****************************************************************

|+| name { class sql }
|+| the sql class is about to handle details that have connected to sql

******************************************************************/
    
    
class sql
    
{

        var 
$sql_function;    // 'INSERT','SELECT....
        
var $args;        // db details or table names
        
var $addition;        // 'WHERE'.....


        
function sql($sql_function,$args,$addition)
        {
            
$this->sql_function $sql_function;
            
$this->args        $args;
            
$this->addition        $addition;
        }
        
            
//The following function is a typical mysql db connection

        
function connect()
        {
            
$db_d      explode(",",$this->args);
            
$server  $db_d[0];
            
$username$db_d[1];
            
$password$db_d[2];
            
$db_name $db_d[3];

            
mysql_connect($server,$username,$password);
            
mysql_select_db($db_name);
                
        }
        

        function 
sql_ord()
        {

            
$query mysql_query($this->sql_function) or die(mysql_error());            
            
        }
            
            
        
    }


    
$connect = new sql("","localhost,root,,bla","");
    
$connect->connect();

    
$sql "INSERT INTO `".MAIN_TABLE."` VALUES('a','b','c') ";
    
$insert  = new sql($sql,"","");
    
$insert->sql_ord();

?>

הנה המחלקה.
המופע הראשון מבצע את ההתחברות למסד.
אשמח גם לקבל טיפים לשיפור בכלליות.

תודה!!!
  Reply With Quote