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
0
votes
2 answers

Not able to access application param from model

There are two models, User and UserProfile. When saving a new user, a single form is used to save data to both model/tables.Here's the controller action. public function actionCreate($role) { $User = new User; $UserProfile = new…
redGREENblue
  • 3,076
  • 8
  • 39
  • 57
0
votes
1 answer

Add column to database from model to controller in yii

In the Yii MVC, I've added a column to my database in my model using: $success = Yii::app()->ft_website_prod->createCommand()->addColumn('ft_website.users', 'columnname', 'varchar(64)'); I now need to know how to get this to execute using the…
Newtt
  • 6,050
  • 13
  • 68
  • 106
0
votes
1 answer

Update two models of different databases with single view in yii

I have a view (_form.php) with fields (name,summary) submit button. If I click on submit button, it should update Name field of One model and Summary field of another model.Both this models are of different databases. Can anyone help on this. I…
Rudra
  • 711
  • 7
  • 13
  • 31
0
votes
0 answers

multiple models classes for sample table

Some of our model files have become very large, and I am tasked to split up functionality into separate modules. I am not sure if it possible to use multiple model classes which are declared in different Modules for the same table? I have tried…
Manquer
  • 7,390
  • 8
  • 42
  • 69
0
votes
3 answers

How to use model object in Yii Controller and View

I have following method: public function actionIndex() { $companyModel = Company::model()->findAll(); $supplierProductModel = SupplierProduct::model()->findAll(); $this->render('index', array( …
J.K.A.
  • 7,272
  • 25
  • 94
  • 163
0
votes
1 answer

Yii Project: How I can prevent from loading related model(child) for a (parent) model?

Salam(Hi), How I can prevent from loading related model(child) for a (parent) model?
Masoud Nazari
  • 476
  • 2
  • 6
  • 17
0
votes
2 answers

Yii Collect Data For Two Or More Models ( Get_Class() Expects Parameter 1 To Be Object, Array Given )

I get this error when I call CreateController : "get_class() expects parameter 1 to be object, array given " Controll/actionCreate() is as follows: public function actionCreate() { $model = new Ogrenci; $model2 =new Adresler; …
Gnosis00
  • 309
  • 6
  • 19
0
votes
1 answer

Yii: 2 models with the same code for beforeValidate

I have a Yii app, and within 2 of the models, I have the code for the beforeValidation method. Does yii have a solution for this, or should I create a component and use parameters for this common code?
Ionut Flavius Pogacian
  • 4,750
  • 14
  • 58
  • 100
0
votes
2 answers

Yii Return Attributes of Joined Models

In Yii, I have media which is tied to a location; I have the relations set up as so: public function relations() { return array( 'users' => array(self::HAS_ONE, 'Users', array('id' => 'user_id')), 'locations' =>…
Devin Dixon
  • 11,553
  • 24
  • 86
  • 167
0
votes
1 answer

Issues with the CSV upload

I am trying to upload CSV file using an Yii framework. I have added the code below : Model
Sumit Gera
  • 1,249
  • 4
  • 18
  • 34
0
votes
1 answer

Yii Make a model instance that cannot be saved

Let's say I have a Widget table and the Yii Model class that goes with it. I want to be able to instantiate it ($tempWidget = new Widget) but somehow make sure it cannot be saved to the database. I want to use the model just for the user to test…
Nathan H
  • 48,033
  • 60
  • 165
  • 247
0
votes
1 answer

Yii Lazy Loading Getting values in through table/model

In Yii, I have a relations set up that use the through option. public function relations() { return array( 'users_relationships' => array( self::HAS_MANY, 'EnvironmentUsers', 'environment_id', 'together'=>true…
Devin Dixon
  • 11,553
  • 24
  • 86
  • 167
0
votes
2 answers

Yii: Following strict MVC rules to ensure that all the business logic is in appropriate places

Sticking to MVC basics in Yii, I am trying to embed my business rules in the model class but facing problem in implementing it. The problem at hand is to stop the user from making duplicate entries and code the function in model class that checks if…
FaisalKhan
  • 2,406
  • 3
  • 25
  • 32
0
votes
2 answers

Where should the (DRY) function to update a Yii model be stored?

I have a Yii application with two separate models, Domain and Page. Domain has a unique field, so I set up a rule ('domain', 'unique') and also create an action that creates a new record if the field is new, otherwise uses the existing record, and…
Rhys
  • 1,581
  • 2
  • 14
  • 22
1 2 3
4