Questions tagged [yii-relations]

47 questions
5
votes
2 answers

Ordered dropDownList using relations?

I have some forms in Yii using the following to get lists of data from related tables in the form of a drop down: dropDownList(CHtml::listData(Company::model()->findAll(array('order' => 'company ASC')))); This works, but that means for every drop…
djt
  • 7,297
  • 11
  • 55
  • 102
3
votes
3 answers

Yii JSON with relations

How I can return object with all relations(ans sub objects relations?). Now I use EJsonBehavior but it returns only first level relations, not sub related objects. My source code: $order = Order::model()->findByPk($_GET['id']); echo…
Marat_Galiev
  • 1,251
  • 5
  • 21
  • 31
3
votes
2 answers

Yii CGridView, displaying multiple columns from related model with filtering capability

I'm pretty new to yii and I bumped into the following problem. I have 2 related tables, ClientTicket and Product with the following structure: ClientTicket id ticket_name client_id product_id Product id type model brand The two tables are…
Raven_ 007
  • 57
  • 1
  • 2
  • 6
3
votes
2 answers

Yii CActiveDataProvider Many to Many

I do not understand how to implement a many to many relation in CActiveDataProvider. At first the situation, I have one Model "Company" with following relations: return array( 'owner' => array(self::HAS_ONE, 'User', 'user_id'), …
Jusophos
  • 41
  • 1
  • 6
3
votes
3 answers

retrieving a sum of two columns from two related models in yii

I'm fairly new working with yii but have plenty of experience with php and sql. I'm hoping that someone more experienced with yii can point me in the right direction. I have two models, Project and Costs, which are related to each other in a many to…
SiggiSmara
  • 51
  • 1
  • 4
3
votes
2 answers

Anyone know of a Yii extension or method for displaying model relations and table schema (including keys and comments) as a flowchart?

I can't seem to find any extension/module/etc that does this nicely. You can access the column metadata as follows, but I want a good way to display it as a flowchart or hypergraph in a model's index. $m=new MyModel;…
111
  • 1,788
  • 1
  • 23
  • 38
2
votes
2 answers

Yii relations trouble when trying to display CGridView from 2 models

Image describing the tables -> https://i.stack.imgur.com/ki2YP.jpg Each of the tables is a model. Main model which shows through CGridView is "RegularTask". Now I need it to display fields from "YearlyTask" in the same row. "hp_id" and "up_id" are…
Xatep
  • 353
  • 1
  • 5
  • 11
2
votes
3 answers

yii 1 relation not working in CGridView

I am trying to get relation where companies table have primary key companyID and division table have Foreign key companyID , what I need in where clause is WHERE companies.companyID = division.companies relation in my model is : public function…
FahadAkram
  • 445
  • 1
  • 5
  • 25
2
votes
1 answer

How to connect two tables with one form in Yii

I recently was introduced into the Yii Framework and am presently developing a web application system for my company. However I noticed that when creating the model in order to give the connection to the respective table, it only allows to choose…
Yoosuf
  • 882
  • 7
  • 33
  • 52
1
vote
2 answers

How make Yii condition on Many_Many relations

have tables: place (id, title, state); movie (id, title, state); schedule (place_id, movie_id, time); use simple yii models: place.relations: 'movies' => array( self::MANY_MANY, 'movie', 'schedule(place_id,movie_id)', …
m15mike
  • 11
  • 1
  • 2
1
vote
2 answers

Yii Framework - two relations via the same "through" table

Mine goal is to have possibility to search Documents via the Users Names and Surnames and also via Recrutation Year and Semester. Documents are related only to Declarations in such a way that Document are connected to exatly one Declaration and…
Pax0r
  • 2,324
  • 2
  • 31
  • 49
1
vote
1 answer

Yii2: How to order a relation by virtual attribute?

I have a class Group, which hasMany Teams and I would like to order them by their score. A team's score is calculated by iterating through its games, so score is not a db-field, it's a virtual read-only attribute. This is my attempt: public function…
Mathias
  • 334
  • 3
  • 5
  • 22
1
vote
1 answer

Yii HAS_MANY relation in search

I would like to create a search form. My price ranges are: public static function getPrice_list(){ $model = array( 0=>"0 - 250.000", 1=>"250.000 - 600.000", 2=>"600.000 - 1.000.000", 3=>"1.000.000 -", …
Siki-Siki
  • 113
  • 1
  • 12
1
vote
0 answers

yii get sum from a table related to a related table

I have these existing tables to work with, can't change them. I have given everything but cannot get a workaround. It is complex even for me to explain the problem so please bear with me. I am using Oracle 10g with Yii 1.1.x, WIndows, Wamp. Models…
Phil
  • 11
  • 3
1
vote
1 answer

Yii. Dynamically add row on AJAX action

I have a link in _form: 'loadChildByAjax')); ?> Some code to renderPartial child _form:
goodsservices as $id => $child): …
Decd
  • 65
  • 8
1
2 3 4