Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Pablo Alba Rico  >  Pablosky MySQL  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example
Class: Pablosky MySQL
MYSQL database access wrapper using MySQLi API
Author: By
Last change: example
Date: 2007-02-11 06:22
Size: 1,114 bytes
 

Contents

Class file image Download
<?php

    
try
    {
    
        
// require class
        
require_once ('class.pablosky_mysql.php');
        
        
// new object
        
$mysqli = new pablosky_mysql ('localhost''root''''pablosky_mysql_test');
        
        
        
        
// insert
        
$insert $mysqli->set_query ("INSERT INTO table1 (name) VALUES ('pablo'), ('juan')");
                
        echo 
"<p>ID last sentence: $insert</p>";
        
        
        
        
// get_results
        
$results $mysqli->get_results ("SELECT * FROM table1");
        
        foreach (
$results as $result)
        {
            echo 
'<p>'.$result->id_name.' '.$result->name.'</p>';
        }
        
        
        
        
// num_results
        
$num_results $mysqli->get_num_rows();
        
        echo 
"<p>Num results: $num_results</p>";
        
        
        
        
// num_fields
        
$num_fields $mysqli->get_num_fields();
        
        echo 
"<p>Num fields: $num_fields</p>";
        
        
        
// get_record
        
$result $mysqli->get_record ("SELECT * FROM table1 WHERE id_name = 1");
        
        echo 
'<p>'.$result->id_name.' '.$result->name.'</p>';
        
        
    
    
    }
    catch (
Exception $ex)
    {
        echo 
'<p>Exception Caught: ' $ex->getMessage() . '<p>Trace: ' $ex->getTraceAsString() . '</p>';
    }


?>