yii-cmodel

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

假如想象 提交于 2019-12-03 12:38:19
问题 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 as value and first_name as display text, but here I want to combine those columns ( first_name and last_name ) and use as display text. in model function getClients() { $Clients = Client::model()->findAll(); $list = CHtml::listData($Clients ,

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

隐身守侯 提交于 2019-12-03 03:06:01
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 as value and first_name as display text, but here I want to combine those columns ( first_name and last_name ) and use as display text. in model function getClients() { $Clients = Client::model()->findAll(); $list = CHtml::listData($Clients , 'client_id', 'first_name'); return $list; } in view echo $form->dropDownList($model,'client_id',$model-

Yii INSERT … ON DUPLICATE UPDATE

巧了我就是萌 提交于 2019-11-30 20:08:14
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` ( `space_id` int(11) NOT NULL, `day` date NOT NULL, `available` tinyint(1) unsigned NOT NULL DEFAULT '0', `price` decimal(12,2) DEFAULT NULL, `offer` varchar(45) DEFAULT NULL, `presale_date` date DEFAULT NULL, `presale_price` decimal(12,2) DEFAULT NULL, `value_x` int(11) DEFAULT NULL, `value_y` int(11) DEFAULT NULL, PRIMARY KEY (`space_id`,`day`), KEY

Yii INSERT … ON DUPLICATE UPDATE

坚强是说给别人听的谎言 提交于 2019-11-30 04:21:56
问题 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` ( `space_id` int(11) NOT NULL, `day` date NOT NULL, `available` tinyint(1) unsigned NOT NULL DEFAULT '0', `price` decimal(12,2) DEFAULT NULL, `offer` varchar(45) DEFAULT NULL, `presale_date` date DEFAULT NULL, `presale_price` decimal(12,2) DEFAULT

multi model forms in yii

会有一股神秘感。 提交于 2019-11-28 17:58:15
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. In my expirience i got this solution to work and quickly understandable You have two models for data you wish collect. Let's say Person and Vehicle . Step 1 : Set up controller for entering form In your controller create model objects: public function actionCreate() { $Person = new Person; $Vehicle = new Vehicle; //.. see step nr.3 $this->render('create',array( 'Person'=>$Person, 'Vehicle'=