<?php
session_start();
require_once ("db_connect.php");
#we create a simple connect without specify the db to connect
$simple = new db_connect("localhost", "my_user", "my_pass");
$simple_con = $simple->connect(); #we receive the connection variable
#we make our sql statements and procedures as normal
#blabla
#blabla
#blabla
$simple->disconnect();
#create connection specifying the data base
$database = new db_connect("my_host", "my_user", "my_pass", "my_db");
$database_con = $database->connect();
#our sql statements
#do
#la
#sol
#re
#mi
#fa
$database->disconnect();
#if we want to save the connection in a session variable we use:
$s = new db_connect("my_host", "my_user", "my_pass", "my_db", true);
#we don't receive the connection variable, the session is stored
#in: $_SESSION["conn"]
$s->connect();
#our sql statements
#bleu
#bleu
#l'amour
#est bleu
$s->disconnect(); #the session variable value is now false
#and the connection is closed
?>
|