PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Vagner vinicius bispo cantuares  >  Simple PHP Database Manager  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Simple PHP Database Manager
Build and run SQL queries with a fluent interface
Author: By
Last change: some fixes.
Date: 1 month ago
Size: 791 bytes
 

Contents

Class file image Download
<?php
require_once 'db_manager.php';

$db = DB_Manager::get_instance();
$db->database();

$db->table = 'users';

# all results.
$result = $db->select('*')->getAll();
echo
'<pre>';
   
var_export($result);
echo
'</pre>';

# one result.
$result = $db->select('*')->where('username', 'cantuares')->get();
echo
'<pre>';
   
var_export($result);
echo
'</pre>';

# insert record.
$result = $db->values(array('username' => 'fulano', 'password' => '***'))->insert();
echo
'<pre>';
   
var_export($result);
echo
'</pre>';

# update record.
$result = $db->set(array('username' => 'sicrano'))->where('username', 'fulano')->update();
echo
'<pre>';
   
var_export($result);
echo
'</pre>';

# delete record.
$result = $db->where('username', 'sicrano')->delete();
echo
'<pre>';
   
var_export($result);
echo
'</pre>';

?>

For more information send a message to info at phpclasses dot org.