CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 3.1 Red Velvet API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.1
      • 6.0
      • 5.4
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Auth
    • Cache
    • Collection
    • Console
    • Controller
    • Core
    • Database
    • Datasource
    • Error
    • Event
    • Filesystem
    • Form
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • Shell
    • TestSuite
    • Utility
    • Validation
    • View

Namespace Behavior

Namespaces

  • Cake\ORM\Behavior\Translate

Classes

  • CounterCacheBehavior

    CounterCache behavior

    Enables models to cache the amount of connections in a given relation.

    Examples with Post model belonging to User model

    Regular counter cache

    [
        'Users' => [
            'post_count'
        ]
    ]

    Counter cache with scope

    [
        'Users' => [
            'posts_published' => [
                'conditions' => [
                    'published' => true
                ]
            ]
        ]
    ]

    Counter cache using custom find

    [
        'Users' => [
            'posts_published' => [
                'finder' => 'published' // Will be using findPublished()
            ]
        ]
    ]

    Counter cache using lambda function returning the count This is equivalent to example #2

    [
        'Users' => [
            'posts_published' => function (Event $event, EntityInterface $entity, Table $table) {
                $query = $table->find('all')->where([
                    'published' => true,
                    'user_id' => $entity->get('user_id')
                ]);
                return $query->count();
             }
        ]
    ]
  • TimestampBehavior
  • TranslateBehavior

    This behavior provides a way to translate dynamic data by keeping translations in a separate table linked to the original record from another one. Translated fields can be configured to override those in the main table when fetched or put aside into another property for the same entity.

    If you wish to override fields, you need to call the locale method in this behavior for setting the language you want to fetch from the translations table.

    If you want to bring all or certain languages for each of the fetched records, you can use the custom translations finders that is exposed to the table.

  • TreeBehavior

    Makes the table to which this is attached to behave like a nested set and provides methods for managing and retrieving information out of the derived hierarchical structure.

    Tables attaching this behavior are required to have a column referencing the parent row, and two other numeric columns (lft and rght) where the implicit order will be cached.

    For more information on what is a nested set and a how it works refer to http://www.sitepoint.com/hierarchical-data-database-2/

OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs