gii.txt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. Title: Gii Support
  2. Author: Dariusz Górecki <darek.krk@gmail.com>
  3. ---
  4. # Model generation {#model}
  5. Since version 1.3.4 you can generate mongo document models based on existing SQL tables, just enable gii generators
  6. provided within package (see below) and use `MongoModel` generator.
  7. # CRUD Generation {#crud}
  8. Now you can generate CRUD for yours MongoDB Documents! just you have to add generator path to yours Gii config
  9. > [Important]
  10. > By default generated models will use mongo `_id` field as a primary key (using MongoId class)
  11. > this generator will use different field as a primary key, if you will override `primaryKey()` method to return
  12. > something different than '_id'. Note that generator cannot handle with multifield primary key,
  13. ~~~
  14. [php]
  15. // in yours main.php config file:
  16. 'modules'=>array(
  17. // ...
  18. 'gii'=>array(
  19. 'class'=>'system.gii.GiiModule',
  20. 'password'=>'yours_password_to_gii',
  21. // add additional generator path
  22. 'generatorPaths'=>array(
  23. 'ext.YiiMongoDbSuite.gii'
  24. ),
  25. ),
  26. // ...
  27. ),
  28. // Now login to Gii and start using Mongocrud generator !
  29. ~~~
  30. # Forms generation {#forms}
  31. - This is a good news, Gii can generate the worst part of developer job, forms for mongo records ;]
  32. - When generating a form from mongo record, comment out embedded docs array, or you'll see error about array/object creation
  33. - For embedded docs just generate forms in separed way for each one