
david camargo - 2006-03-09 13:29:32 -
In reply to message 1 from tanveer
Ok Man, here is a example of how to use the class
Let says, that you have a table products with this columns: ID, PRODUCT, PRICE
<?php
include("class.DbManager.php");
$db = new DbManager;
$db->setDbParams();
//check if a product already exists
$query = "SELECT id FROM products WHERE product = 'test'";
if($db->checkExists($query))
echo "The product exists";
//insert a new product
$query = "INSERT INTO products(product, price) VALUES('test',10)";
$id = $db->execInsert($query);
if($id!=NULL)
echo "Product Inserted with id $id";
//execute a select
$query = "SELECT * FROM products";
$res = $db->execQuery($query);
//transform the resultset into array
if($res!=NULL)
$res = $db->res2array($res);
//execute delete or update queries
$query = "DELETE FROM products WHERE id = 1";
if($db->execUpdate($query))
echo "Product Deleted Successfully";
?>