Cdbexception When I Want To Save A Model

Hi,

I can’t save a model, I just wanna update a column value in my MySql. In native PHP I can do in easily, but in Yii no, and I can’t solution on the internet.





145                 {

146                     $turn=Turn::model()->find("`setting`='current_turn'");

147                     $turn->attributes=array('value'=>'200');

148                     $turn->update();                   

149                 }



The problem is at the 148. line, with the update method. So the Yii can find the model, it is not empty. But can’t update, and I don’t know why, this codesnippet I found here on the forum as a right solution, but it seems I use in the bad way…

The error message only is:

Column name must be either a string or an array.

Here, how the tbl_turn looks like:




--

-- Table structure for table `tbl_turn`

--


CREATE TABLE IF NOT EXISTS `tbl_turn` (

  `setting` varchar(100) NOT NULL,

  `value` int(11) NOT NULL DEFAULT '0'

) ENGINE=MyISAM DEFAULT CHARSET=latin1;


--

-- Dumping data for table `tbl_turn`

--


INSERT INTO `tbl_turn` (`setting`, `value`) VALUES

('current_turn', 0);



Solved.

Hi,

please see it…

http://yiibook.blogspot.in/2012/06/update-query-in-yii.html

i hope you get the point…