When using using Doctrine 1.2.1 and Zend Framework 1.9.x to generate classes from Yaml/db each Base class (which includes the table definition) extends the Doctrine_Record class.
I need to find a way of telling Doctrine to extend my own Base class, or find a different solution to a master/slave db setup using Doctrine.
Example generated model:
abstract class My_Base_User extends Doctrine_Record
However I need it to be automatically generated as:
abstract class My_Base_User extends My_Record
And the answer is (drumroll)
Typical, as soon as I ask the question I manage to find the answer. I’m recording it here in case anyone else has the same issue.
You can pass in the parameter ‘baseClassName’ into the generateModels* methods and Doctrine will use that as the Base record class.
Doctrine_Core::generateModelsFromDb('models', array('master'), array('generateTableClasses' => true, 'baseClassName' => 'My_Record'));
or using Cli:
$options['generate_models_options'] = array(
'pearStyle' => true,
'baseClassPrefix' => 'My_',
'baseClassName' => 'My_Record',
'classPrefix' => '',
'classPrefixFiles' => false,
'generateTableClasses' => true,
$cli = new Doctrine_Cli($options);
Richard Bates @ Zend Developer Zone wrote a good article on my favorite ORM Doctrine integration in Zend;
Rich Internet applications built with Adobe Flex and Flash Builder have been steadily gaining a foothold in enterprise development for quite some time. As the platform has grown and evolved, PHP has also made amazing progress toward becoming a mature, powerful object-oriented language with rapid adoption and dozens of frameworks and design pattern implementations. As PHP continues to prosper, developers are able to borrow more and more of the things Java has got right, taking one check after another from the “Java-only” column. One outstanding example of this is object-relational mapping (ORM). A few different PHP ORM implementations are available, and all of them have positive attributes. However, after some experimentation, I’ve found that Doctrine is my favorite.
Read the complete story;
Object-relational mapping with Doctrine, Flash Builder, and PHP.