Login   Register  
PHP Classes
elePHPant
Icontem

File: usage.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Cristian Rusu  >  DB Connect  >  usage.php  >  Download  
File: usage.php
Role: Example script
Content type: text/plain
Description: usage sample
Class: DB Connect
Query a database and fetch the result and metadata
Author: By
Last change: added more on sample usage file
Date: 2005-02-09 09:26
Size: 3,485 bytes
 

Contents

Class file image Download
<?
    $db 
= new DBConn();
    
$rezults=$db->get("SELECT * FROM mytable");
    if (
$rezults["&rows"]!=0){//we have records
        
for($i=0;$i<$rezults["&rows"];$i++){
            
//output result as you like
            //with a simple debugger that allow you to inspect the $results array, you can learn in less than a minute how to use the array's data loaded by the class
        
}
    }

?>

here is a print_r of one of my users table:
Array
(
    [&status] => 1
    [&cols] => 11
    [&rows] => 7
    [&total] => 77
    [&fieldname] => Array
        (
            [0] => iduser
            [1] => fullname
            [2] => usernick
            [3] => password
            [4] => iduserlevel
            [5] => status
            [6] => email
            [7] => phone
            [8] => lastlogin
            [9] => downloads
            [10] => alert
        )

    [iduser] => Array
        (
            [0] => 21
            [1] => 22
            [2] => 23
            [3] => 24
            [4] => 25
            [5] => 26
            [6] => 28
        )

    [fullname] => Array
        (
            [0] => Demo Admin
            [1] => Moderator Demo
            [2] => General Football
            [3] => Gen Literature
            [4] => Second Admin
            [5] => Don Tester
            [6] => Bryce Gronlund
        )

    [usernick] => Array
        (
            [0] => test
            [1] => mod
            [2] => genf
            [3] => genl
            [4] => admin
            [5] => don
            [6] => bryce
        )

    [password] => Array
        (
            [0] => xxxx
            [1] => xxxxx
            [2] => xxxxxx
            [3] => xxxxxxx
            [4] => xxxxxxxx
            [5] => x
            [6] => xx
        )

    [iduserlevel] => Array
        (
            [0] => 1
            [1] => 2
            [2] => 3
            [3] => 3
            [4] => 1
            [5] => 2
            [6] => 3
        )

    [status] => Array
        (
            [0] => 1
            [1] => 1
            [2] => 1
            [3] => 1
            [4] => 1
            [5] => 1
            [6] => 1
        )

    [email] => Array
        (
            [0] => test@domain.com
            [1] => mod@demo.com
            [2] => gen@demo.com
            [3] => genf@demo.com
            [4] => admin@demo.com
            [5] => don@solarwinds.com
            [6] => don@solarwinds.com
        )

    [phone] => Array
        (
            [0] => 11245785
            [1] => 12454574
            [2] => 
            [3] => 1245778
            [4] => 11
            [5] => 444555
            [6] => 250-787-0098
        )

    [lastlogin] => Array
        (
            [0] => 2004-09-26 17:42:04
            [1] => 2004-09-26 17:42:04
            [2] => 2004-09-26 17:42:04
            [3] => 2004-09-26 17:42:04
            [4] => 2004-09-26 17:42:04
            [5] => 2004-09-26 17:42:04
            [6] => 2004-09-26 17:42:04
        )

    [downloads] => Array
        (
            [0] => 3
            [1] => 0
            [2] => 0
            [3] => 0
            [4] => 0
            [5] => 0
            [6] => 0
        )

    [alert] => Array
        (
            [0] => 0
            [1] => 0
            [2] => 0
            [3] => 0
            [4] => 0
            [5] => 0
            [6] => 1
        )

)