Questions tagged [Active Record] (259)

1
answer

Rails. ActiveRecord. Association?

There is a table Images. How to make Association Images yourself using migration? How to call additional linking table? What to prescribe in the Image model?
bernardo_Stamm asked October 10th 19 at 10:12
5
answers

The AR library for PHP

Decided to use ActiveRecord on one of my sites. Please share the experience in the direction of the smallest barrier to entry and thoughts — whether AR in order to implement it? p.s. Google shared with me the two libraries github.com/kla/php-activerecord and www.phpactiverecord.org/
samanta_Langosh asked October 10th 19 at 03:46
7
answers

A good implementation of ActiveRecord in PHP, in the manner of Rails

Good day! Implement ActiveRecord in PHP, in the manner of a dozen counterparts (Rails, Yii and so on). For example, there is the following code that retrieves a list of objects: $users = Users::model()->findAll()->all; The question arose about the correctness of the implementation. The fact is that according to Wikipe...
muriel.Jacobs asked October 9th 19 at 17:57
3
answers

The principle of building models database for PHP?

There are 3 main Paterna building models database. This Data Table Gateway, Actrive Record, Data Mapper. I'd like to understand for what purpose is each of them to decide pros and cons. I'm not experienced enough to make them yourself, so ask for help from Habra residents.
henriette_Mante asked October 8th 19 at 01:55
1
answer

The sample of linked tables

Good afternoon. Please help me to understand. How to get the values communication article.category in the sample, ArticleData::model()->with('article','article.category')->findAll(); Try this: $article = ArticleData::model()->with('article','article.category')->findAll(); echo $article[0]->article->cate...
ellen_Johns asked October 8th 19 at 01:06
2
answers

How to write relations() ?

Something today I didn't sleep, can't do niebanalna thing. mysql> show fields from users; +------------+---------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +------------+---------------------+------+-----+---------+----------------+ | id | int(10) unsigned | NO ...
vito.Hoeg asked October 7th 19 at 18:34
3
answers

Is it possible to organize a polymorphism in ActiveRecord without type field?

Actually the task is to pull on a long-existing database (the structure of which is strongly desirable not to change) the application on RoR. But in this database there are entities, with which it would be good to work through STI. Then there is a problem, because to define a class that should be created is the required fie...
pink.Ratke26 asked October 7th 19 at 17:35
1
answer

Why a model is saved?

There are two models — User and Image communication is one to one. Such a record: user.image ||= Image.new Calls the Insert, saving an empty image in the table. I would like to understand why is this happening? save anywhere is not called. UPD. This happens only if the User connection is defined as :has_one :image C belon...
josiane_Altenwerth19 asked October 7th 19 at 14:50
4
answers

The choice of PHP ORM, ActiveRecord

Please advise with a choice of ORM Framework for PHP. Previously used Yii and Yii with ActiveRecord, but now we need to choose some framework. (Doctrine, Propel, etc.). It is desirable to have well documented.
audie.Orn asked October 7th 19 at 13:40
3
answers

Rails HABTM relationship. How to save?

Hello! There are 2 models: class Hashtag < ActiveRecord::Base has_and_belongs_to_many :photos attr_accessible :name *** end class Photo < ActiveRecord::Base has_and_belongs_to_many :hashtags, :uniq => true *** end Join table: def up create_table :hashtags_photos, :id => false do |t| t.integer :photo_...
gaylord.Emmeric asked October 3rd 19 at 15:34