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 4554530
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:05:59+00:00 2026-05-21T17:05:59+00:00

I am putting together a DB driven website with kohana and I need to

  • 0

I am putting together a DB driven website with kohana and I need to be able to track revisions. So I have the data behind the individual pages in two tables. The first is the generic entity table that I use for keeping track of all the sites content. It contains basic information: resource uid, uri alias, creating user, creation date, and publishing user, and content model. The revision table contains rev_id, resource uid as FK, title, page content, revision creator, revision date, and publish approver.

The site will lookup a page by resource uid or uri alias and return the most recent published revision. However from the uri the user can roll back the page to earlier revisions by including an upper date limit in the uri or a -# to roll back # revisions.

So the page controller will be taking in the resource uid, possibly a date, and a revision rollback count, requesting the appropriate record from the models, and passing the appropriate record to the view.

Creating new pages will update both tables, updating pages will update one table, and deleting tables will effect 1 table.

Should I be creating two models, the entity model and the revision model? Or should I just have the one logical model that abstracts the actual structure?

  • 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-05-21T17:06:00+00:00Added an answer on May 21, 2026 at 5:06 pm

    I had similar problem, and chose the way with two models.
    Sorry for code sample, i wrote it only for illustration purposes.
    To avoid problems with db structure changes, i just inherited revision model from entity model, and overloaded parent fields (or just unsetted them if i didnt need them).

    Looked like this:

    <?php
    
    // file /application/classes/model/page.php
    class Model_Page extends Jelly_Model {
    
        public static function fields() {
            return array(
                'id' => new Field_Primary(),
                'content' => new Field_String(),
                'author' => new Field_BelongsTo(array(
                    'foreign' => 'user',
                    'column' => 'author_id'    
                )),
                'creation_date' => new Field_Integer(),
                'uri' => new Field_String()
    
            );
        }
    
        //here we init the model, using previously defined static method
        public static function initialize(Jelly_Meta $meta){
            $meta->table('pages')->fields(self::fields());
        }
    
    }
    
    // file /application/classes/model/page/draft.php
    class Model_Page_Draft extends Model_Page {
        public static function initialize(Jelly_Meta $meta) {
            //here we inherit all the parent models' fields 
            //to skip the dirty work
            $fields = parent::fields();
            //then we overload model propertires
            //with fields relevant to draft model
            $fields['rev_id'] = new Field_Integer();
            //and choose other table to work with
            $meta->table('page_draft')->fields($fields);
    
    
        }
    }
    

    PS Excuse my english

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

Sidebar

Related Questions

I'm putting together a system to track customer orders. Each order will have three
We are putting together a website for a client and their IT Team have
I am putting together a staff database and I need to be able to
I am putting together a fairly simple web app that uses user inputted data
I'm putting together a JavaScript object called ListBox which takes a two-dimensional array, and
I'm putting together some demo pages, and one of the things I want to
I'm putting together a basic photoalbum on appengine using python 27. I have written
I'm putting together a basic UITableView before getting some feedback of how the data
little background: currently putting together a website that is selling products, many of which
I'm putting together a portfolio website which includes a number of images, some of

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.