I am using Principle with Codeigniter, I have used my rating column $ this-> hasColumn ('ratings' 'Array', 1000); I'm using $ res = principle: getTable ('resource') -> find ($ resource_id); $ Res-> rating = $ rating; $ Res-> Save (); But only $ rating is entered, overwriting the last value, I have to store the ratings as an array, example: 1,5,4,2,3,5,1 etc. How do I add / retrieve the value from the table column with the defined theory as an array? (I am using mysql)
It has been managed to do this, I might be down It can be useful for posting code of
public function add_rating () {$ rating = (int) $ this- & gt; Uri-> Segment (3); $ Resource_id = (int) $ this- & gt; Uri-> Segment (4); If ((is_numeric ($ Rating)) & amp; amp; ($ Rating & gt; 0) & amp; ($ Rating & lt; = 5)) {$ res = Principle :: getTable ('Resources') - & gt; ($ RESOURCE_ID); $ Ratings = $ res- & gt; Rating; $ Ratings [] = $ rating; $ Res-> Rating = $ Rating; // resonance '& lt; Pre & gt; '; // echo print_r ($ ratings); $ Res-> Save (); } Redirect ('/ home / show /'. $ Resource_id); }
Comments
Post a Comment