PHP Classes

File: sample.php

Recommend this page to a friend!
  Classes of Tom Schaefer   QDataObject   sample.php   Download  
File: sample.php
Role: Example script
Content type: text/plain
Description: Sample for data object with one result object
Class: QDataObject
Access MySQL query results as objects
Author: By
Last change: working on factory
Date: 16 years ago
Size: 566 bytes
 

Contents

Class file image Download
include_once('config.inc.php');

@mysql_connect(db_default_host, db_default_user, db_default_password) OR die(mysql_error());
mysql_select_db(db_default_database) OR die(mysql_error());

$sql = "SELECT * FROM customers";

$result = mysql_query($sql);
if(empty($result)) {
  echo "You have to provide a valid resource. Maybe your Query or DB Connection has errors.";
  exit;
}

$dataObject = QDataObject::getInstance('mysql',$result);
$dataObject->byPage(($_GET["p"]?intval($_GET["p"]):1));


print "<pre>";
print_r($dataObject);
print "</pre>";