PHP Classes

File: test.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Raul  >  PHP MySQLi extension class  >  test.php  >  Download  
File: test.php
Role: Example script
Content type: text/plain
Description: Test and Exemple
Class: PHP MySQLi extension class
Execute common queries with MySQLi
Author: By
Last change:
Date: 2 years ago
Size: 1,042 bytes


Class file image Download
// This is a basic exemplo of the use of the ExMysqli Class
// The class extends the MySqli class
// So you can use the native mysqli methods as well

// I always use these functions on tests scripts, helps me to show the content on the screen
function dump($var){echo '<pre>';var_dump($var);echo '</pre>';}
br($repeat = 2){echo str_repeat('<br/>', $repeat);}


$db = new ExMysqli('localhost', 'root', '', 'test');

// Here the data to be inserted
$data = array(
'nome' => 'My Name',
'email' => '',
'telefone' => '45514551',
'endereco' => 'Madson Avenue'

// Inserting the data
$db->insert('tabela', $data);

// Getting the content
$result = $db->select('*')->from('tabela')->get();

// If there's more then 0 rows returned then fetch and show
if($result->num_rows > 0){
$result->fetch_all(MYSQLI_ASSOC) as $field=>$row) {

// Delete the row with id 1
$db->delete_by_id('tabela', 'id', 1);