Questions tagged [yii-cmodel]

CModel is one the basic classes of the yii framework for data model objects.

CModel is one the basic classes of the framework for data model objects.

CModel is the base class providing the common features needed by data model objects.

CModel defines the basic framework for data models that need to be validated.

Read more: http://www.yiiframework.com/doc/api/1.1/CModel

59 questions
2
votes
1 answer

Yii - Include field from another model

my question consists of two parts: 1, I'm developing small ticketing software for technical support. I have model and views for Workorder (type of ticket). I would like to include another model's field/input into this model. This model is called…
Numline1
  • 159
  • 7
2
votes
2 answers

Browse Yii Relations with limits

I have a Community model and a Content model. Each Content has a community_id column. I created this simple relation: $relations['contents'] = array(self::HAS_MANY, 'Content', 'community_id','order'=>'weight DESC, id DESC'); (note the ORDER) In the…
Nathan H
  • 48,033
  • 60
  • 165
  • 247
2
votes
1 answer

Yii Joined table but not all selected data is retrieved

I have the following criteria in my controller. $criteria = new CDbCriteria; $criteria->select = 't.*,b.*,c.*'; $criteria->join = "INNER JOIN tbl_patient_chair b ON b.patient = '0005' INNER JOIN tbl_chair c ON…
Sahil
  • 1,959
  • 6
  • 24
  • 44
2
votes
1 answer

MVC pattern usual practice for saving more than one model in a transaction

I want to save two models in a transaction but it will be used on more than one view. Should I put that transaction in one of those models? Or should I somehow reuse the controller action? What is the best practice for MVC pattern in this…
user1750290
  • 125
  • 9
1
vote
2 answers

actionUpdate() in Yii multimodel form?

In Yii multimodel form we just used actionCreate() to create the form of two models in a single view.Ok everything is fine upto here.But when we will update the two models in a single view of multimodel how the models will be defined here? Let me…
NewUser
  • 12,713
  • 39
  • 142
  • 236
1
vote
1 answer

Yii scope and relation issue

I've something like this $model=UserCategory::model()->findAll(array('with'=>array('user.department','totalCount'=>array('condition'=>"user.department.name='Science'")))); but it says Unknown column 'user.department.name' I know why it says so but…
iThink
  • 1,239
  • 3
  • 13
  • 34
1
vote
1 answer

How to dynamically change model rules in YII framework?

I have form in YII and it needs to change model rules dynamically. Is it possible?
bzut
  • 11
  • 1
  • 2
1
vote
1 answer

YII scenario: how to?

What If I have an input field for example: UserEmail: UserPhoneNumber: UserOldPasword: UserNewPassword: UserRetypePassword: And on my action update I will only require UserNewPassword if UserOldPassword is not empty else the only thing that needs…
NEWBIE
  • 365
  • 2
  • 7
  • 23
1
vote
2 answers

Yii - are most of functions in model files supposed to be static function?

I'm a Yii framework user. mostly I define functions as public static function in my model files like the example function below. public static function getTrashedPostCount(){ $connection=Yii::app()->db; $sql = "SELECT…
Hayato
  • 559
  • 1
  • 10
  • 15
1
vote
2 answers

How to get filetype and size of uploaded image with Yii

I have a problem with Yii: I have a Model called Slider.php and a controller called SliderController.php . I wrote this code to make the user upload an image: public function actionCreate() { $model=new Slider; // Uncomment the following…
1
vote
2 answers

MVC - Many-to-Many relations--their own models?

My straight forward question: If I have a many-to-many relation in my database (as the following tables) User Role UserRole user_id role_id user_id role_id Should UserRole have its own…
jelgh
  • 705
  • 1
  • 6
  • 22
1
vote
2 answers

Yii: When to use single table inheritance. Clarifying usage and understanding

Assuming that I have an online store whereby products are stocked and sold by either integer quantity or decimal weight. There are different types of products. Not all items are related. I need to decide whether I should put them in separate tables…
Gravy
  • 12,264
  • 26
  • 124
  • 193
1
vote
2 answers

MVC ORM and user related data

Yii provides ORM based development which is OK for normal development. My question is, in my application there are many user related data like user info, user settings, user preferences and so on. Here user means the current logged in user. If…
Gunah Gaar
  • 525
  • 2
  • 10
  • 28
1
vote
1 answer

Adding where close on Gii generated CRUD

I am beginner with Yii and I used GII to create a CURD table. Everything is working fine but I only want to fetch certain record from the database by putting a where clause (for example "where client gender is male). I cannot find where the data is…
Sahil
  • 1,959
  • 6
  • 24
  • 44
1
vote
1 answer

Set Attribute of Static Model CModel

I am modifying existing functional code that relied on CActiveRecord. I am now connecting to sybase, which has no schema driver, so I am rewriting with CModel instead of CActiveRecord. My problem may be that I don't understand this general OOP…
MaxPowers
  • 474
  • 1
  • 4
  • 18