Questions tagged [has-many]

has_many indicates a master-detail relationship.

A master record has many detail records.
For example if we have buildings and rooms we can say that one building has_many rooms.
In a database, with tables/models, this relationship implies that rooms will have a foreign key for which building they belong to (the relationship will be belongs_to)

1446 questions
-2
votes
1 answer

How my model Laravel could be return me all prices for each item only last date in hasMany?

I have 2 models(market,price_item), i want return last prices for each item (model 2) for 1 market (model 1). i have in my model 1: public function prices() { return $this->hasMany(MarketPrices::class,…
Cleoh
  • 25
  • 1
  • 5
-2
votes
2 answers

Get the related table values in cakephp3

i have 3 tables like A,B and C.. A and B has relation but A and C dont have any connection. B and C related. In cakephp3 index action returns the A and B relation only .. i Need to take the table C data. Table…
-2
votes
2 answers

C# ClassA has many ClassB, how to access ClassA instance method from ClassB instance

My C# program needs to receive xml data and store it in sql database. I have Batches which has many Instructions. I implement the classes thusly: class Batch { public string batchUID { get; set; } public Instruction[] instructionArray { get;…
-2
votes
1 answer

How to loop through multiple models in Phalcon with.volt files

I have three models in my project and I need to loop through all these models to display the content of 3 tables. SO wat I wnat to know is how to display a has many to belongs to relation in .volt file(a join in sql)?
Ugur Ertas
  • 25
  • 8
-3
votes
3 answers

Rails Has Many Active Record Query

User has many comments and comments belong to user. Comment table has status column which is boolean type. Now I want to get users whose last comment has status true. How can this be done in ActiveRecord query?
-3
votes
3 answers

has_many doesn't fetch all when includes(:association).where("association.something = ?", value)

I need your help: I have Three Models: Phonogram has_many PhonogramInstrument: class Phonogram < ActiveRecord::Base #... things has_many :phonogram_instruments, source: :filter, dependent: :destroy, inverse_of: :phonogram has_many…
1 2 3
96
97