PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Dwaine Halberg   mySQLEz   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: example file
Class: mySQLEz
MySQL database access wrapper
Author: By
Last change:
Date: 13 years ago
Size: 1,478 bytes
 

Contents

Class file image Download
<?php
$dbuser
= "root";
$dbserver = "localhost";
$dbpass = "";
$dbname = "demo";
include
'classes/mysqlez.php';
//******** BEGIN mySQLEz DEMO*********//

$db = new mySQLEz( $dbserver, $dbuser, $dbpass, $dbname );

if(
$db == TRUE )
{
    echo
'<h3>mySQLEz ( v '. mySQLEZ::DB_CLASS_VER .' ) sucessfully connected!</h3>';
}
else
{
    echo
'<h3>Error: mySQLEz ( v '. mySQLEZ::DB_CLASS_VER .' ) could not connect to db!</h3>';
}
?>
<hr>
<?php
$sql
= "SELECT * FROM pages WHERE id = 1";

$rows = $db->fetchObj( $sql );?>

<p><a href="docs.html">mySQLEz docs</a></p>
    <h4>fetchObj Usage:</h4>
<?php foreach( $rows as $row ): ?>

    <h4>Page Name: <?php echo $row->title ?></h4>
    <?php echo $row->body;
endforeach;

//show array output
$sql1 = "SELECT * FROM pages WHERE id = 2";
$rows1 = $db->fetchArray( $sql1, $type= MYSQL_BOTH );
?>
<hr>
<h4>fetchArray Usage</h4>
<?php

foreach( $rows1 as $row ):?>

    <h4>Page Name: <?php echo $row['title'] ?></h4>
    <?php echo $row['body'];
endforeach;

//show row output
$rows = $db->fetchRow( 'pages', $fields='*', 'id', 2 ); ?>
<hr>
<h4>fetchRow Usage:</h4>

<?php foreach( $rows as $row ): ?>
<h4>Page Name: <?php echo $row->title ?> </h4>
<?php endforeach; ?>
<hr>
<h4>fecthCount Usage:</h4>
<p>Total pages: <?php echo $numRows = $db->fetchCount( 'pages', 'id', $keyColName='', $id=''); ?></p>
<hr>
<h4>varDump Usage</h4>
<?php $db->varDump($rows);?>
<hr>