📜 ⬆️ ⬇️

Named Scope for CakePHP

In Ruby on Rails, there is such a useful thing as a named scope, which provides an elegant and convenient way to search for data in a model. For clarity, an example:

class User < ActiveRecord::Base
named_scope :active, :conditions => {:active => true}
named_scope :inactive, :conditions => {:active => false}
end
#
User.active # , User.find(:all, :conditions => {:active => true})
User.inactive # , User.find(:all, :conditions => {:active => false})

and what have CakePHP to do with it?

')

Source: https://habr.com/ru/post/46735/


All Articles