If you can't read please download the document
Upload
marcingy
View
2.470
Download
2
Embed Size (px)
DESCRIPTION
Entity field query api session
Citation preview
2. The need for a query builder
Every query must be hand crafted for a specific database 3. View offers the ability to create custom queries on the fly
4. Views based queries are not always optimal D7 changes this 5. Views in core
6. Lacks the structured tpl structure that views provides 7. Need to be able to write code Why is this possible?
8. Plugable storage 9. Fields in Core
You can build your own Fields
Instances
10. Entities and bundles
11. Example of a node entity 12. hook_entity_info_alter() Bundle is a sub class of an entity
13. Taxonomy terms are classified by vocabularies 14. Bundles can have there own properties 15. Fields
Core comes with predefined field types
CCK minus user and node reference these are still contrib 16. Defining a field 17. Creating a field $vocabulary = (object) array('name' => 'Newsworthy subject', 'machine_name'=> 'newsworthy_subject'); taxonomy_vocabulary_save($vocabulary); $vocabularies = taxonomy_vocabulary_get_names(); $field = array( 'field_name' => 'newsworthy_subject', 'type' => 'taxonomy_term_reference', 'settings' => array( 'required' => FALSE, 'allowed_values' => array( array( 'vid' => $vocabularies['newsworthy_subject']->vid, 'parent' => 0, ), ), ), ); field_create_field($field); 18. Bundles
19. Widgets can be defined here along with display modes
20. field_create_instance 21. Updating a field foreach (ex_taxonomy_get_content_types() as $content_type) { $content_type = node_type_set_defaults($content_type); node_type_save($content_type); // just for good measure - it won't do anything if the field is // already present node_add_body_field($content_type); // set the weight of the body instances. $body_instance = field_info_instance('node', 'body', $content_type->type); $body_instance['required'] = TRUE; $body_instance['widget']['weight'] = 1.2; $body_instance['display']['full'] = array( 'label' => 'hidden', 'type' => 'text_default', ); field_update_instance($body_instance); } 22. Entity field api
23. What does that mean?
24. Drupal 7 we don't need to store fields in just mysql
25. Mongodb and actively being used by examiner.com Will allow for sites to select the most appropriate storage mechanism but for scalability nosql is likely to become the weapon of choice The same query will work over multiple storage engines 26. Entity query api
27. Filters
28. Property conditions 29. Field conditions Sorts, Count, Limit 30. More here http://api.scratch.drupal.org/api/drupal/includes--entity.inc/class/EntityFieldQuery/7 31. Examples
Now for some code
Native queries
32. Mongo 33. No Kittens were harmed
34. Some basic mongo cli queries 35. The joy of theming!! Why D7 has multiple options for storage
36. The nature of d7 storage in mysql is problematic for scalability 37. New api allows for backends to swap out with little rework in the drupal layer 38. Views in core??
39. Lack the templating structure of view 40. Has no concept of relationships But....
41. Supports all queries in views that do need relationships 42. Lightweight 43. Renderable arrays make theming a joy anyway!!! 44. Thank you