Login   Register  
PHP Classes
elePHPant
Icontem

File: sample.list.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tom Schaefer  >  QDataObject  >  sample.list.php  >  Download  
File: sample.list.php
Role: Example script
Content type: text/plain
Description: sample for a result set as object list
Class: QDataObject
Access MySQL query results as objects
Author: By
Last change: add type sample
Date: 2008-07-13 09:30
Size: 1,079 bytes
 

Contents

Class file image Download
<?php 

/**
You have to provide an existing connection
for getting a valid resource from mysql, otherwise
it will no work.
*/
define('db_default_host''localhost');
define('db_default_user''root');
define('db_default_password''');
define('db_default_database''database');

@
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 employees where employee_id=1";

$result mysql_query($sql);

$dataObject = new QDataObject($result);

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

print 
"<pre>";
print_r($dataObject->getListByName('LastName'));
print 
"</pre>";

/**
fetches the first and lastname of the third row of the object list
*/
print "<pre>";
print_r($dataObject->typLastName(2));
print_r($dataObject->getLastName(2));
print_r($dataObject->getFirstName(2));
print_r($dataObject->getLastNameOfMdEmployees(2));
print_r($dataObject->getFirstNameOfMdEmployees(2));
print 
"</pre>";