<?php
// 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>';}
function br($repeat = 2){echo str_repeat('<br/>', $repeat);}
include_once 'Database/ExMysqli.php';
$db = new ExMysqli('localhost', 'root', '', 'test');
// Here the data to be inserted
$data = array(
'nome' => 'My Name',
'email' => 'mymain@domain.com',
'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){
foreach($result->fetch_all(MYSQLI_ASSOC) as $field=>$row) {
dump($row);
br();
}
}
// Delete the row with id 1
$db->delete_by_id('tabela', 'id', 1);
|