SlideShare a Scribd company logo
Marc Ingram Entity Field Query API Examiner.com http://drupal.org/user/77320
The need for a query builder Where we are now Drupal 6 has no concept of a query builder http://buytaert.net/starting-to-work-on-drupal-7  Feb 2008 Every query must be hand crafted for a specific database
View offers the ability to create custom queries on the fly View 3 allows for plugable backends
Views based queries are not always optimal D7 changes this
Views in core Why for developers? No GUI
Lacks the structured tpl structure that views provides
Need to be able to write code Why is this possible? Fields in core
Plugable storage
Fields in Core What does fields in core mean? Bundles/Entities This is the basic building block Taxonomy terms, Taxonomy vocabularies, Users, Nodes, Files You can build your own Fields Allows you define fields that can be used by entities Instances Associates fields with given entities and bundles
Entities and bundles hook_entity_info() Allows you to create new entities
Example of a node entity
hook_entity_info_alter() Bundle is a sub class of an entity CCK content type
Taxonomy terms are classified by vocabularies
Bundles can have there own properties
Fields All entities are now fieldable This means the concept of cck is no longer restricted to nodes Core comes with predefined field types Text, Options, Number, List CCK minus user and node reference these are still contrib

More Related Content

PPTX
Drupal 7 entities & TextbookMadness.com
PDF
Entities in drupal 7
PDF
Your Entity, Your Code
PDF
Drupal Entities - Emerging Patterns of Usage
PDF
Top Ten Reasons to Use EntityFieldQuery in Drupal
PPTX
Build your own entity with Drupal
PDF
What's New in Drupal 8: Entity Field API
PDF
Drupal 8: Forms
Drupal 7 entities & TextbookMadness.com
Entities in drupal 7
Your Entity, Your Code
Drupal Entities - Emerging Patterns of Usage
Top Ten Reasons to Use EntityFieldQuery in Drupal
Build your own entity with Drupal
What's New in Drupal 8: Entity Field API
Drupal 8: Forms

What's hot (20)

PDF
Drupal 8 Sample Module
PDF
Drupal 8: Entities
PDF
Drupal 8: Routing & More
PPT
Synapseindia object oriented programming in php
PPT
Advanced php
PPTX
J query1
PDF
Dependency Injection
PDF
Field api.From d7 to d8
PDF
The State of Lithium
PPT
J query
PDF
Dependency Injection in Laravel
PDF
Dig Deeper into WordPress - WD Meetup Cairo
PDF
Dependency Injection with PHP and PHP 5.3
PDF
Your code sucks, let's fix it - DPC UnCon
PDF
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
PDF
Doctrine and NoSQL
PDF
Doctrine for NoSQL
PDF
Dependency injection-zendcon-2010
PDF
50 Laravel Tricks in 50 Minutes
PPT
Propel sfugmd
Drupal 8 Sample Module
Drupal 8: Entities
Drupal 8: Routing & More
Synapseindia object oriented programming in php
Advanced php
J query1
Dependency Injection
Field api.From d7 to d8
The State of Lithium
J query
Dependency Injection in Laravel
Dig Deeper into WordPress - WD Meetup Cairo
Dependency Injection with PHP and PHP 5.3
Your code sucks, let's fix it - DPC UnCon
Decouple Your Code For Reusability (International PHP Conference / IPC 2008)
Doctrine and NoSQL
Doctrine for NoSQL
Dependency injection-zendcon-2010
50 Laravel Tricks in 50 Minutes
Propel sfugmd
Ad

Viewers also liked (12)

ODP
Things i wish i knew about drupal commerce
ODP
Field Api Drupalcon Paris
KEY
D7 entities fields
ODP
Drupal 7 field API
PDF
Deconstructing drupal commerce
PDF
Drupal Commerce 2014
PDF
An Introduction to Drupal Commerce & Real World Examples
PDF
Entities, Bundles, and Fields: You need to understand this!
PPTX
Drupal commerce performance profiling and tunning using loadstorm experiments...
PDF
Drupal 7 Entity & Entity API
PDF
Get on with Field API
PDF
Drupalize your data use entities
Things i wish i knew about drupal commerce
Field Api Drupalcon Paris
D7 entities fields
Drupal 7 field API
Deconstructing drupal commerce
Drupal Commerce 2014
An Introduction to Drupal Commerce & Real World Examples
Entities, Bundles, and Fields: You need to understand this!
Drupal commerce performance profiling and tunning using loadstorm experiments...
Drupal 7 Entity & Entity API
Get on with Field API
Drupalize your data use entities
Ad

Similar to Entity Query API (20)

PDF
Compass Framework
PPT
Mongo-Drupal
PPT
Zend framework 03 - singleton factory data mapper caching logging
PPTX
Googleappengineintro 110410190620-phpapp01
ODP
This upload requires better support for ODP format
PDF
12 core technologies you should learn, love, and hate to be a 'real' technocrat
PDF
Efficient content structures and queries in CRX/CQ
PDF
Intake 37 ef2
ODP
Practical catalyst
PDF
黑豹 ch4 ddd pattern practice (2)
PDF
Learning To Run - XPages for Lotus Notes Client Developers
PDF
Intake 38 data access 5
PPTX
Building nTier Applications with Entity Framework Services (Part 1)
PPT
Advanced Web Development
PPTX
Building nTier Applications with Entity Framework Services (Part 1)
PPT
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
PPT
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
DOC
Quiz With Answers Drupal
PPTX
Abstract #236765 advanced essbase java api tips and tricks
PPT
Compass Framework
Mongo-Drupal
Zend framework 03 - singleton factory data mapper caching logging
Googleappengineintro 110410190620-phpapp01
This upload requires better support for ODP format
12 core technologies you should learn, love, and hate to be a 'real' technocrat
Efficient content structures and queries in CRX/CQ
Intake 37 ef2
Practical catalyst
黑豹 ch4 ddd pattern practice (2)
Learning To Run - XPages for Lotus Notes Client Developers
Intake 38 data access 5
Building nTier Applications with Entity Framework Services (Part 1)
Advanced Web Development
Building nTier Applications with Entity Framework Services (Part 1)
JavaOne 2008 - TS-5793 - Groovy and Grails, changing the landscape of Java EE...
Architecture | Busy Java Developers Guide to NoSQL | Ted Neward
Quiz With Answers Drupal
Abstract #236765 advanced essbase java api tips and tricks

Entity Query API

  • 1. Marc Ingram Entity Field Query API Examiner.com http://drupal.org/user/77320
  • 2. The need for a query builder Where we are now Drupal 6 has no concept of a query builder http://buytaert.net/starting-to-work-on-drupal-7 Feb 2008 Every query must be hand crafted for a specific database
  • 3. View offers the ability to create custom queries on the fly View 3 allows for plugable backends
  • 4. Views based queries are not always optimal D7 changes this
  • 5. Views in core Why for developers? No GUI
  • 6. Lacks the structured tpl structure that views provides
  • 7. Need to be able to write code Why is this possible? Fields in core
  • 9. Fields in Core What does fields in core mean? Bundles/Entities This is the basic building block Taxonomy terms, Taxonomy vocabularies, Users, Nodes, Files You can build your own Fields Allows you define fields that can be used by entities Instances Associates fields with given entities and bundles
  • 10. Entities and bundles hook_entity_info() Allows you to create new entities
  • 11. Example of a node entity
  • 12. hook_entity_info_alter() Bundle is a sub class of an entity CCK content type
  • 13. Taxonomy terms are classified by vocabularies
  • 14. Bundles can have there own properties
  • 15. Fields All entities are now fieldable This means the concept of cck is no longer restricted to nodes Core comes with predefined field types Text, Options, Number, List CCK minus user and node reference these are still contrib
  • 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 A bundle is a collection of fields associated with an entity Sub types can have different bundles – story vs business
  • 19. Widgets can be defined here along with display modes Each field can have a different widget on a different bundle field_update_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 Entity query api The ability to create queries that are agnostic with regards field storage engines
  • 23. What does that mean? What is field storage?
  • 24. Drupal 7 we don't need to store fields in just mysql Main choices at the moment sql_storage (core)
  • 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 What does a entity field query look like
  • 29. Field conditions Sorts, Count, Limit
  • 31. Examples How to roll your own hook_field_storage_query() Now for some code An example query Benefits of entity_cache and memcache Native queries Mysql
  • 32. Mongo
  • 33. No Kittens were harmed Didn't we mention portable queries..... A demo and code walkthrough in which no kittens are harmed!!! Mysql vs mongodb spot the difference
  • 34. Some basic mongo cli queries
  • 35. The joy of theming!! Why D7 has multiple options for storage Not all sites have the same need
  • 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?? Entity query api Negatives Lacks the flexibility of views
  • 39. Lack the templating structure of view
  • 40. Has no concept of relationships But.... Database agnostic
  • 41. Supports all queries in views that do need relationships
  • 43. Renderable arrays make theming a joy anyway!!!
  • 44. Thank you Any questions?