<?php
/*
http://coolpenguin.net/persistclass
for updates, documentation, tutorials
*/
// connect to database (executing demo 1)
require('demo1-connection.php');
// defining persistence class with mappign information
class TestTable extends PersistClass {
protected $sqlTableName = 'TESTTABLE';
protected $sqlPrimaryKey = 'testid';
protected $sqlColumnToFieldMapping = array('testcolumn' => 'testcolumncalleddifferently');
}
// preparation for the demo (ensuring there is a row / object with id = 1)
try {
$id = 1;
$newTestTable = new TestTable($id);
} catch(NoResultException $e) {
$newTestTable = new TestTable();
$newTestTable->setId($id);
$newTestTable->insertDb();
}
$id = 1;
$testObj = new TestTable($id);
$testObj->getData('testcolumncalleddifferently');
$testObj->setData('testcolumncalleddifferently', 'grrrrr');
$testObj->updateDb();
echo 'Test successful';
?>
|