View Single Post
  #3 (permalink)  
Old 11-08-2007, 09:14 AM
rashaverak rashaverak is offline
Junior Member
 
Join Date: Nov 2007
Posts: 3
Default

Quote:
Originally Posted by frosty1 View Post
you should be able to get all the info you need with describe table.
It seems you missunderstood me. I am talking here about MVC, exactly about the "M". I need to generate the php classes from create statement sql. It shouldnt be problem to generate some basics, at least something like this from the documentation according to the foreign keys

PHP Code:
class Bugs extends Zend_Db_Table_Abstract
{
    protected 
$_name            'bugs';

    protected 
$_dependentTables = array('BugsProducts');

    protected 
$_referenceMap    = array(
        
'Reporter' => array(
            
'columns'           => 'reported_by',
            
'refTableClass'     => 'Accounts',
            
'refColumns'        => 'account_name'
        
),
        
'Engineer' => array(
            
'columns'           => 'assigned_to',
            
'refTableClass'     => 'Accounts',
            
'refColumns'        => 'account_name'
        
),
        
'Verifier' => array(
            
'columns'           => array('verified_by'),
            
'refTableClass'     => 'Accounts',
            
'refColumns'        => array('account_name')
        )
    );
}

class 
BugsProducts extends Zend_Db_Table_Abstract
{
    ...
    protected 
$_referenceMap    = array(
        
'Product' => array(
            
'columns'           => array('product_id'),
            
'refTableClass'     => 'Products',
            
'refColumns'        => array('product_id'),
            
'onDelete'          => self::CASCADE,
            
'onUpdate'          => self::RESTRICT
        
),
        ...
    );

Reply With Quote