<?php
//
// +--------------------------------------------------------------------------+
// | |
// | XS PHP Library Generic Classes Library |
// | |
// | Copyright (c) 2001-2002 XSPHPLib Group. |
// | |
// +--------------------------------------------------------------------------+
// | |
// | Distributed under the terms of the GNU Lesser General Public License as |
// | published by the Free Software Foundation version 2.1 |
// | See the GNU Lesser General Public License for more details. You should |
// | have received a copy of the GNU Lesser General Public License along with |
// | this package; if not, write to the Free Software Foundation, Inc., |
// | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
// | |
// +--------------------------------------------------------------------------+
// | |
// | Authors: Robert Bala <hide@address.com> |
// | |
// +--------------------------------------------------------------------------+
//
// $Id: dbmysql.php,v 1.2 2002/11/28 09:51:38 rbala Exp $
include_once('../inc/object.inc.php');
include_once('../inc/dbmysql.inc.php');
$broker = new DBBroker();
$broker->setParam('hostname', 'localhost');
$broker->setParam('database', 'mysql');
$broker->setParam('username', 'root');
$broker->setParam('password', 'root');
object_checkError($broker->open());
echo '<p>There are <b>' . $broker->tableCount() . '</b> tables.</p>';
$tables = $broker->tableNames();
foreach ($tables as $table) {
echo $table . '<br>';
}
$query =& $broker->query("SELECT * FROM user");
if (!object_isError($query)) {
echo '<p>Field name fot table user:</p>';
$fields = $query->fieldNames();
foreach ($fields as $field) {
echo $field . '<br>';
}
echo '<p>Table user entries:</p>';
$count = $query->rowCount();
while ($row = $query->fetchRow()) {
echo $row[0] . ' ' . $row[1] . ' ' . $row[2] . ' ' . $row[3] . '<br>';
}
}
object_checkError($broker->close());
?>