PHP Classes

File: mysqlTest.php

Recommend this page to a friend!
  Classes of Mhyk Duterte  >  Hybrid MySQL  >  mysqlTest.php  >  Download  
File: mysqlTest.php
Role: Example script
Content type: text/plain
Description: Sample class usage
Class: Hybrid MySQL
MySQL database access wrapper
Author: By
Last change:
Date: 17 years ago
Size: 958 bytes


Class file image Download

// Require the class
// Database info

// Instantiate the MySQL Class
// Parameters: Database Host, Database User, Database Password, Database Name, Persistent Connection (true or false)
$mysql = new MySQL($dbHost,$dbUser,$dbPass,$dbName);

// Check to see if errors occured
if ($mysql->isError()) {
// Print the error message

// The SQL to execute
$sql = "SELECT field FROM table";

// Execute the query
$result = $mysql->query($sql);

// Check for errors
if (! $result) {
// Print the error message

// Loop through the rows using the fetch() method
// Parameters: [optional] fetch mode (FETCH_ARRAY , FETCH_ASSOC or FETCH_OBJECT)
while ($row = $result->fetch(FETCH_OBJECT)) {
$row->field.'<br />';

'Rows: '.$result->numRows();

// Free the result in memory

// Close the connection


For more information send a message to info at phpclasses dot org.