Login   Register  
PHP Classes
elePHPant
Icontem

File: example3.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Indrek Altpere  >  ORM mapping class(like Hibernate), maps database table rows to objects  >  example3.php  >  Download  
File: example3.php
Role: Example script
Content type: text/plain
Description: iterator example
Class: ORM mapping class(like Hibernate), maps database table rows to objects
Store and retrieve objects in MySQL table records
Author: By
Last change:
Date: 6 years ago
Size: 525 bytes
 

Contents

Class file image Download
<?php

require_once 'Mysql.php'
require_once 
'ExampleObject.php';
Mysql::Init('hostname''username''password''databasename'); 

$exampleobj = new ExampleObject();
//create iterator to select all data from table, deny cacheing
$iterator = new BaseObjectIterator('SELECT * FROM '.$exampleobj->GetTableName(), $exampleobjfalse);

foreach(
$iterator as $index => $obj) {
  
$obj->field2 .= ' changed';
  
//if object defines some special function, call if needed
  //save changed object
  
$obj->Save();
}
?>