// Which class to use?
if (isset($_GET['class'])) {
$class = $_GET['class'];
} else {
$class = 'Product';
}
// include that class
include_once('classes/'.$class.'.php');
// make the object
$obj = new $class;
it may be better to replace this with
$obj = DB_DataObject::factory($class);
It's not documented yet.. - but I think it should become the prefered way to create dataobjects... (as it includes and instantates them..)
// Maybe an existing record was chosen? If yes, fetch it before making the form!
// (If you don't, a new one will be created on form submit)
if (isset($_GET['id']) && is_numeric($_GET['id'])) {
$obj->get($_GET['id']);
}
$obj->setFrom($_GET);
if (!$obj->find()) {
// nothing found..
}
--
Can you help out?
Need Consulting Services or Know of a Job?
http://www.akbkhome.com