Zend Framework 1.8 Models and Mappers auto generate
Every time that u will make a change inside the DB u don't need to change manually your model or your mapper just run the model generator. Right now just run this script after you create your database or after any DB shema modification
If u need a model, buisnessObjet or an Entity just call it from models/Entity folder for example
new Application_Model_Entity_User();
and put your custom code inside it. Same thing for the mapper :
new Application_Model_Mapper_User();
By default U can call all your model getters and setters alreday auto generated. Like:
$user = new Application_Model_Entity_User();
$user->setId(1)
->setName('Amine')
->setLastName('Cherif')
->setEnglishLanguageLevel(0)
->setPoor(TRUE);
And the default Mapper like
$userMapper = new Application_Model_Mapper_User();
$userMapper->save($user);
Your mapper have by default those methods:
fetchAll() // Get an array of all buisness objects stored on the current table
populateForm($id) // Get the appropriated array to be populated by Zend_Form
find($id) // Similar to getElementById
delete($id) // If u guess what that method do u are the next Steve Jobs ;)
save($buisnessObject) // so hard to explain :P
Put the CommandLine into Zend library Folder Copy and paste bin folder on your project folder
-
Open your console and go inside the bin folder
-
and run: sudo php modelgenerator.php
==> don't forget to change the Model folder permissions
Adding many to many and one to many relations
It's not a secret be smart and do like that u understand it's all what we do all the time else forget about your promotion !
- Thank u for all your feed back and feel free to commit new crazy things .
- Sorry about my poor English (I need a cute English Teacher Girl Friend ;) )
- Good Luck!