Questions tagged [model]

Part of the MVC pattern, the Model manages the behaviour and data of the application.

The MVC (Model, View, Controller) pattern separates objects into one of three categories — models for maintaining data, views for displaying all or a portion of the data, and controllers for handling events that affect the model or view(s).

Frameworks such as Laravel, Rails, Django and ASP.NET MVC apply this pattern in the web development domain.

18996 questions
4
votes
2 answers

Store PHP class settings in variables or return them from methods

I see two different implementations when people handle classes that extend other classes and provide functionality based on certain setting inside the class. Variables are used to store settings. Methods are used to return settings. Using…
preyz
  • 3,029
  • 5
  • 29
  • 36
4
votes
1 answer

Extjs hasone association

I have Person model, it contains id, first_name, last_name etc and merital_id field. I also have Merital model contains only 2 field: id and title. Server responses JSON like: { success: true, items: [ { "id":"17", …
Luft-on
  • 179
  • 1
  • 13
4
votes
1 answer

How to save an object when you do not know if its parent objects exist or not?

I have three tables, Business: id name Office: id name business_id Employee: id name office_id Employee's have office_id as a foreign key and Offices have business_id as a foreign key. I have a domain object/entity that relates to…
Mark
  • 5,423
  • 11
  • 47
  • 62
4
votes
1 answer

ASP.NET MVC model that uses more that one db table

I'm new to using MVC and I'm trying to make a model that uses other models. Say I have in my database 2 tables, i'll just call them Table1 and Table2 for the sake of this question. In my MVC project these correspond to Model1 and Model2. Now I'd…
tonyd24601
  • 205
  • 1
  • 9
4
votes
3 answers

Codeigniter abstract base model

Is it possible to implement an abstract base model in Codeigniter? I have created a abstract class which has basic CRUD functionalities but I am receiving a "Cannot instantiate abstract class" error. The abstract model is located in…
GazNicoll
  • 51
  • 1
  • 6
4
votes
3 answers

Specify item fields to Load using Sharepoint 2010 Client OM

How can I dinamically generate/specify a list of item fields I want to load when querying a list using the Client OM? This is possible to do using the tag on the CAML query, but this loads additional unwanted fields, making the payload bigger. See…
dsanatelli
  • 66
  • 1
  • 3
4
votes
2 answers

C# UpdateModel with custom data instead of FormCollection

For reference this is in a C# MVC2 website. I'm looking to save a data using a Model in my database, but I need to do it with custom data rather than the FormCollection I am used to. Here is how I typically do it: TryUpdateModel(userToUpdate, new…
Mr Lahey
  • 656
  • 3
  • 15
  • 31
4
votes
2 answers

Good name for a has_many through association

I've read about many to many relationship in rails 3 and saw that HABTM has been "deprecated", as in one should use has_many :through most of the time. I saw plenty of examples where the Join Model has a clear name, for example Magazine, Suscriber =…
Pontek
  • 149
  • 11
4
votes
3 answers

How can I add a derived column to my Yii model?

In Yii, I need to add a "derived" column to any resultset from my model. The column doesn't actually exist in the database table. For example, say I have an Activity model. There are only two types of Activities: (1) Income, or (2) Expense. If I…
Turgs
  • 1,729
  • 1
  • 20
  • 49
4
votes
1 answer

Codeigniter form validation external callbacks

I need to check if the user_id that was inserted exists. I was going to use callbacks in Codeigniter form validation but they require the function that does the validation be in the controller. I'm using this on many pages across multiple…
Dylan Buth
  • 1,648
  • 5
  • 35
  • 57
4
votes
2 answers

Can this object model for my Java application be improved?

I'm designing a Java application that will be used by contractors to diagram residences. Currently, I'm in the modeling phase and am creating a UML class diagram. My issue is that I'm not sure the ideal way to model some of my objects. Users will…
NickAbbey
  • 1,201
  • 2
  • 10
  • 17
4
votes
3 answers

Codeigniter MY_Model class

I'm trying to write my own MY_Model base class but I'm facing a weird problem: /core/MY_Model.php function __construct() { if ( !empty($this->table)) { // query db, etc. } else { // even though…
Steph
  • 149
  • 1
  • 2
  • 14
4
votes
1 answer

How to decouple repository and entities

This is a question on domain model design. Let's say for a domain design involving users and groups, we have the following interfaces to implement: interface IUser { string Name{get;} DateTime DOB {get;} } interface IGroup { string Name…
Ben
  • 282
  • 2
  • 10
4
votes
2 answers

Tableless model with ActiveRecord associations in Rails 3.2

My application configuration includes some values which need to be used in AR relationships. I'm aware this is an odd and potentially criminal thing to attempt, but I need to maintain the configuration as a textfile, and I honestly think I have a…
John Schulze
  • 2,198
  • 3
  • 20
  • 22
4
votes
2 answers

How do I fix table x has no column named y?

I edited a model in django and as a result I get the error: "table reserve_time has no column named reservation" for the below models: from django.db import models import datetime class Club(models.Model): establishment =…
sharataka
  • 5,014
  • 20
  • 65
  • 125
1 2 3
99
100