Maison  >  Questions et réponses  >  le corps du texte

ruby - Rails数据库模型操作记录

**count**:
      Person.count(:conditions => "age > 26")
      Person.count(:conditions => "age > 26 AND job.salary > 60000", :include => :job) # because of the named association, it finds the DISTINCT count using LEFT OUTER JOIN.
      Person.count(:conditions => "age > 26 AND job.salary > 60000", :joins => "LEFT JOIN jobs on jobs.person_id = person.id") # finds the number of rows matching the conditions and joins.
      Person.count('id', :conditions => "age > 26") # Performs a COUNT(id)
      Person.count(:all, :conditions => "age > 26") # Performs a COUNT(*) (:all is an alias for '*')
巴扎黑巴扎黑2758 Il y a quelques jours764

répondre à tous(0)je répondrai

Pas de réponse
  • Annulerrépondre