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
16
votes
4 answers

multi model forms in yii

How to create a multi-model form in Yii? I searched the entire documentation of Yii, but got no interesting results. Can some one give me some direction or thoughts about that? Any help will be appreciable.
NewUser
  • 12,713
  • 39
  • 142
  • 236
9
votes
4 answers

In Yii framework how can I Combine columns and show as display string in dropdownlist

I have a dropDownList in my view, it is populating from clients table, the table contains columns like first_name, last_name,id etc., Now I want to show the first_name and last_name as display text and id as value in drop down list, I'm done with id…
arun
  • 3,667
  • 3
  • 29
  • 54
8
votes
7 answers

Yii INSERT ... ON DUPLICATE UPDATE

I am working on a Yii project. How can I use the ON DUPLICATE feature of MySQL ( http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html ) when doing a save() on a Yii model? My MySQL is as follows: CREATE TABLE `ck_space_calendar_cache` ( …
Nathan H
  • 48,033
  • 60
  • 165
  • 247
7
votes
2 answers

difference between ActiveRecord and model() in yii?

What is the relation or difference between ActiveRecord and model in YII ? i was trying to log is_object(CActiveRecord::model('Project')); and was expecting false but it returned true; Since the logging indicated that it's an object, i thought it is…
Rajkamal Subramanian
  • 6,884
  • 4
  • 52
  • 69
6
votes
3 answers

Yii CGrid pagination and sorting with CArrayDataProvider doesnt work

I built a custom function in my model and return the raw data: function(){ ... $connection=Yii::app()->db; $command=$connection->createCommand($sql); $rows=$command->queryAll(); return $rows; } $campModel = $model->function.. I then use those rows…
Danny Valariola
  • 1,118
  • 5
  • 26
  • 41
5
votes
4 answers

CModel vs CFormModel vs CActiveRecord

I am building a db intensive application in yii . So performance and security are naturally a concern . Apart from that form validation is also a major criteria . For security I plan to use parameter binding for all Sql Queries . For validation I…
Varun Jain
  • 1,901
  • 7
  • 33
  • 66
4
votes
2 answers

Yii: Saving multiple models from a single form and checking for existing record

Below is the relation between three tables I have. Now, while creating a new user through user/create action, the form takes input for both user table fields and the unit name. The unit name here isn't a dropdown (using that is not an option), but…
redGREENblue
  • 3,076
  • 8
  • 39
  • 57
4
votes
2 answers

Yii Command Line Does Not Autoload Models

I'm trying to run a command on the command line with Yii. My method requires a model but when I run the command, Yii says model does not exist, as if it is not auto-loading it. My class is fairly short and simple: class ImportCommand extends…
Devin Dixon
  • 11,553
  • 24
  • 86
  • 167
4
votes
1 answer

In Yii, why use CActiveDataProvider instead of Post::model()->findAll()?

I see CActiveDataProvider used in the controller actionIndex() function. Is there any difference between using this instead of simply Post::model()->findAll()?
Turgs
  • 1,729
  • 1
  • 20
  • 49
3
votes
1 answer

What is the Yii way to CModel lists (of other CModel lists or not)?

I have been playing with Yii for a couple of months now, and to structure the code the Yii way, I was wondering how to best have models being lists of other models. Yii seems to have models very close to DAO conceptually while the MVC design pushes…
Nicolas Grasset
  • 453
  • 2
  • 11
3
votes
10 answers

Adding Data with Yii Framework

This is my user table structure : +----------------+------------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra …
Eray
  • 7,038
  • 16
  • 70
  • 120
2
votes
3 answers

ActiveRecord search returns 'Syntax error or access violation' error

In my Yii application, I have a model that represents siteconfig table and have four columns: integer config_id, string key, string value, string update_time. I created a model using Gii (to ensure that I will not make any mistakes). I don't…
Netorica
  • 18,523
  • 17
  • 73
  • 108
2
votes
1 answer

Yii saving array to model attributes

I'm trying to update a row when a user gets an authentication key, but my $model->attributes remain empty when I save my $data array to them. Here's what I have: public function redeemKey($key,$subscription_id){ $key =…
visevo
  • 791
  • 7
  • 23
2
votes
1 answer

Yii insert series of data

So, I got a series of data that I need to insert into a table. Right now I am using a for loop to iterate through each entry and save the model one by one. But that doesn't seem like a good way to do it, moreover using transaction would be an issue.…
redGREENblue
  • 3,076
  • 8
  • 39
  • 57
2
votes
2 answers

Yii get Model as parameter

I am trying to modify 1 controller to work with 2 models. This is what I have done with loadModel function in my controller public function loadModel($id, $_model) { if (isset($_model)){ $model=$_model::model()->findByPk($id); // syntax…
Irakli
  • 1,151
  • 5
  • 30
  • 55
1
2 3 4