PHP Classes

File: example.php

Recommend this page to a friend!
  Packages of Sinan   MySqli Plus   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Usage
Class: MySqli Plus
MySQL database access wrapper based on MySQLi
Author: By
Last change: - Connection type changed
Date: 12 years ago
Size: 1,119 bytes
 

Contents

Class file image Download
<?php   
/**  
* @table : users   
*  | id | first_name | last_name | 
*  ------------------------------- 
*    1  | joe         | fox 
*    2  | exm         | example 
*    3  | admin       | admin 
**/
$myConfig = include "config.php";
require_once("class.mySqliPlus.php");


    $mysqli  = new mySqliPlus($myConfig);
    $table = 'users';
     
    //row count
    echo '<pre>';
    echo  $mysqli->rowCount($table,"where first_name ='joe'");
    echo '</pre>';


    //get rows
    echo '<pre>'; 
    print_r($mysqli->getRows($table,'*',"where first_name ='joe'"));  
    echo '</pre>';

    //insert data
    $data_arr = array(
        'id' => '',
        'first_name' => "joe's data",
        'last_name' => "test",
        );

    $rowID = $mysqli->insert($table, $data_arr);
    echo $rowID; // it returns inserted id

    //update data
    $data_arr = array(
        'first_name' => "joe's Updated Data",
        'last_name' => "testUpdated",
        );
    $mysqli->update($table, $data_arr,'where id=1');

    //delete data
    echo $mysqli->delete($table,'id=2');