PHP Classes
elePHPant
Icontem

File: usage.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Jiri Kocman  >  New DB Class  >  usage.php  >  Download  
File: usage.php
Role: Example script
Content type: text/plain
Description: usage tips
Class: New DB Class
Class for access MySQL and Sybase ASE database ser
Author: By
Last change: Some changes
Date: 12 years ago
Size: 2,418 bytes
 

Contents

Class file image Download
<?php
/* vim: set ts=2 sw=2: */
// +----------------------------------------------------------------------+
// | PHP version 4.0 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/2_02.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Ji&#345;í Kocman <jirka@komplikator.cz> |
// +----------------------------------------------------------------------+

/**
* usage
* @package db_class
* @author Ji&#345;í Kocman - jirka@komplikator.cz
* @version $Id: usage.php,v 1.6 2002/11/17 03:55:48 jirka Exp $
*/

/* jednoduchý p&#345;iklad využití t&#345;ídy */

// require config souboru a samotné t&#345;ídy
require_once("db_class_config.php");
require_once(
$_dbEngine . "_db_class.php");

// inicializace t&#345;ídy + p&#345;ipojení k db pomocí konstruktoru
$db = new db($_dbServer, $_dbUser, $_dbPass, true, $_dbName);

// p&#345;ipojení k databázi bez použití konstruktoru - stará verze
/*
$db = new db();
$db->db_Connect($_dbServer, $_dbUser, $_dbPass, true);
$db->db_Select_DB($_dbName);
*/

// SQL dotaz
$sql = $db->db_Query("SELECT * FROM user");
// provedení smy&#269;ky

while($row = $db->db_Fetch_Row($sql))
{
    echo
$row[0] . "<br>";
}

echo
'<br><br>';
echo
$db->show_data($sql);
echo
'<br><br>';
echo
nl2br($db->show_data($sql,0,0,1));

echo
'<br><br>';

// nová funkce
echo 'radku = ' . $db->db_fetch_into(0, &$test, $sql); // nutno p&#345;edávat referenci na pole !!!
echo '<br><br>';
foreach(
$test as $value)
{
    echo
$value . "<br>";
}

echo
'<br><br>';

// informace o verzi mysql
echo $db->db_get_client_info();
?>