mysql classes to make your website more faster

Discussion in 'PHP' started by astkboy2008, Dec 18, 2009.

  1. #1
    hello every one
    today
    i get tow php classes
    its working with mysql
    this type of classes make the working with mysql by the php
    more easier
    SimpleDB 0.1.9
    ​

    Mysql driver class for PHP5. Clearly programmed, very easy to use in your application.
    Simple example - getting result from MySQL database
    This is the most simples example, shows how to get results from database.
    
    require_once('mysql_driver.php'); //include class file
    
    $DB = new DB_MYSQL; //connect to database
    
    $DB->query('SELECT host FROM user'); //send query
    
    $buffer = $DB->fetch()) //fetch result to array - basic method (from last query)
    
    echo $buffer['host']; //where 'host' is a name of desired row in table
    
    PHP:
    But is better to handle variable on query to make sure that you are fetching from right query!
    
    $query1 = $DB->query('SELECT host FROM user'); //send query
    $query2 = $DB->query('SELECT password FROM user'); //send query
    $query3 = $DB->query('SELECT * FROM help_topic'); //send query :)
    $query4 = $DB->query('SELECT user FROM user'); //send query :)
    
    while($buffer = $DB->fetch($query2)) 
    
            { 
    
            echo $buffer['password'].'<br>'; 
    
            }
    
    PHP:
    Now you are sure, that result will come from:
    $query2 = $DB->query('SELECT password FROM user'); //send query
    PHP:
    Would you like to know number of affected rows by your query?No problem :)
    echo 'Affected rows: '.$DB->numRows(); //List affected records by last query
    PHP:
    Hmm, maybe you want to count queries and and them to your site footer? Here you go:
    echo 'Queries: '.$DB->queries; //Number of queries done by script
    PHP:
    Simple yes? All functions are simple
    You are sitting in your admin panel and doing nothing, lets optimize our database!
    $DB->optimizeDB();  //database optimization
    PHP:
    I know, you want to see all queries done by the script, and time of executions
    First, you will have to enable debug mode:

    In mysql_driver.php

    private $debug = 2;
    PHP:
    Now after some queries and other functions you can paste this:

    echo $DB->showSyntaxes();
    PHP:
    HOME PAGE

    class_database_0.1.9.zip [7.99 KB]

    mysql db class 0.4

    1. It extracts the data you request as rows directly, so you don't need to do it by yourself.
    2. Has memcached support ( just added )
    3. Has profiling option to log queries to the database
    HOME PAGE
    mysql-db-php-class-v0.4.zip [3.59 KB]

    ​
     
    astkboy2008, Dec 18, 2009 IP
  2. ghprod

    ghprod Active Member

    Messages:
    1,010
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    78
    #2
    great application!!!

    great work!!

    i see this class work like ezsql that i use before :)

    maybe u can add some feature to fetch result as ARRAY_N, like active record concept :)
     
    ghprod, Dec 19, 2009 IP
  3. astkboy2008

    astkboy2008 Peon

    Messages:
    211
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes sure in can make loops very fast
     
    astkboy2008, Dec 19, 2009 IP