Bill Karwin wrote:
Most people put the table classes in their models directory. If your
model is simple enough, you may be able to use the table class itself as
the model.
Other models may be more complex, requiring access to multiple table,
etc. For these you'd write a model class (extending nothing) that
utilizes any table classes it needs.
And yes, you do need to write code for the table classes. They are not
generated. Perhaps one could write a tool that generates skeleton table
classes. The simple case is very easy:
$db = Zend_Db::factory(...);
foreach ($db->listTables() as $tableName) {
$fp = fopen("models/$tableName.php", "w");
fwrite($fp, "class $tableName extends
Zend_Db_Table_Abstract\n{\n}\n");
fclose($fp);
}
If not specified, the name of the class is used as the name of the
database table.
If not specified, the primary key is automatically queried from the
database.
Other metadata, like the list of columns, is automatically queried from
the database.
There is no automatic discovery of foreign key references in ZF at this
time (maybe someday).
Hi this is a problem if its automatically querying to building the
fields, Ive been using the PEAR DB_DataObject package exclusevily for
the model stuff for years, though id like to move to PDO / PHP5 and the
extension version doesnt seem like it is updated in a while
http://pecl.php.net/package/DBDO. It generates fields as variables etc
which are usable in the model class so is not called all the time. Its
also married with a package called FormBuilder for RAD form stuff which
is what the admin side of this project uses, so not sure if its worth
migrating that stuff if ZF also does RAD stuff with Zend_Db_Table or
keep it in PHP4.
Thanks for the tip on generating I'll build a shell script for that to
update them or whatever I guess. Is thats all thats required, just to
have empty classes ?