Hi,
I have been Googling for methodologies to 'fake' OO database
arrangements using a standard RDBMS without much success.
At least I think I need to fake it :-)
I'm using MySQL as my database backend (the RDBMS) and, obviously,
cakePHP (the OO bit) as the application language.
My application data setup has this kind of arrangement:
class Run extends AppModel
{
var $belongsTo = array(
'Exec' =>
array('className' => 'Exec',
'foreignKey' => 'exec_id',
), // ... and others
}
Now there are many types of exec, with varying, non-overlapping sets of
data. For example, execType1 may have 3 fields, whereas execType2 may
have 50 fields all completely different from those in execType1.
But from a Run's point of view they are handled exactly the same.
(Well, for data structure purposes they are, obviously the view
handling is very different.)
So whay I have done is to make a table for the Exec class that contains
the name of the table that contains the real exec data along with the
index into that table, e.g.:
entry 1
tablename: "exectype1"
index: 45
entry 2
tablename: "exectype2"
index: 3
etc.
So when a Run asks for the information about the Exec, the Exec
controller just finds the name of the relevant table and redirects to
that controller:
function view($id) {
$data = $this->Exec->read(null, $id);
$table = $data['Exec']['table'];
$index = $data['Exec']['table_idx'];
$this->redirect("/$table/view/$index");
}
[It's not *exactly* like that but close enough]
So this all works but it looks like a dodgy design decision, especially
now that I have to start searching through the list of Execs to find
failures before showing the Runs that have failures.
Does anyone else have any experiences with this type of design? Even of
the 'Aaagh, whatever you do, don't do THAT" type.
Allan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---