PHP Classes

how to use that

Recommend this page to a friend!

      Simple DB Handler  >  All threads  >  how to use that  >  (Un) Subscribe thread alerts  
Subject:how to use that
Summary:guide us about the uses of this class
Messages:4
Author:tanveer
Date:2006-03-09 06:22:13
Update:2006-03-10 18:21:18
 

  1. how to use that   Reply   Report abuse  
Picture of tanveer tanveer - 2006-03-09 06:22:13
Dear
i have set parameter for connection of database but could not understand how to uset that can you explian that littel bit to me.
Thanks
Regards

  2. Re: how to use that   Reply   Report abuse  
Picture of david camargo 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";
?>

  3. Re: how to use that   Reply   Report abuse  
Picture of tanveer tanveer - 2006-03-09 15:08:43 - In reply to message 2 from david camargo
ok thanks for explanation but i thought it is something more then that any way thanks

  4. Re: how to use that   Reply   Report abuse  
Picture of david camargo david camargo - 2006-03-10 18:21:18 - In reply to message 3 from tanveer
Ok, i made this class to delegate simple db functions to other classes, sorry if it's too simple.