Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8662259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:41:29+00:00 2026-06-12T16:41:29+00:00

I have models Page and Commit. Page has many Commits. But sometimes i need

  • 0

I have models Page and Commit. Page has many Commits.
But sometimes i need to get just one last commit for page, and sometimes to get history of page commits (20 last or all).

I wrote this code for models:

class Page extends ActiveRecord\Model {
    static $has_many = array(
        array('commits',
            'select'=> 'content',
            'order' => 'id DESC',
            'limit' => 1
        ));
}
class Commit extends ActiveRecord\Model {
    static $belongs_to = array(
        array('page'));
}

So what i need to do to have a chance for display all commits ([‘limit’ => 20] for ex.)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T16:41:30+00:00Added an answer on June 12, 2026 at 4:41 pm

    It’s a bit of a workaround, but this should do it… kinda simulating scopes from Rails:

    class Page extends ActiveRecord\Model {
        static $has_many = array(
            array('limited_commits',
                'class_name' => 'Commit',
                'select'=> 'content',
                'order' => 'id DESC',
                'limit' => 1
            ),
            array('all_commits',
                'class_name' => 'Commit',
                'select' => 'content',
                'order' => 'id DESC'
            )
        );
    }
    class Commit extends ActiveRecord\Model {
        static $belongs_to = array(
            array('page'));
    }
    

    And then just use the ‘scope’ you need:

    Page::first->limited_commits
    Page::first->all_commits
    

    It’s not a really overall solution, but it should do the trick…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have several view models on one page, how do you ensure that
Suppose I have a Book model, which contains many Page models. The routing for
I have 2 models, User and Entity. I need to on my entities page,
I have 2 models: ContactGroup and Contact. ContactGroup contains many Contacts. In the page,
I'm trying to show what I have in models.py on the page postlogin.html but
I have the following models: User: hasOne Profile, Page hasMany Comment Comment: belongsTo User,
I have the following types and classes: namespace MVC.Models public class Page { public
I'm currently managing multiple models from a single SITE MANAGER page. I have the
In my Rails app, I have a model Page which represents one HTML article
I have 2 models: Pages ------------ Page User S500 John Gimp John WoW John

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.