Index: trunk/extensions/Reviews/sql/Reviews.sql |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | CREATE TABLE IF NOT EXISTS /*_*/review_ratings ( |
29 | 29 | rating_id INT unsigned NOT NULL auto_increment PRIMARY KEY, |
30 | 30 | rating_review_id INT unsigned NOT NULL, |
31 | | - rating_type TINYINT unsigned NOT NULL, |
| 31 | + rating_type VARCHAR(255) NOT NULL, |
32 | 32 | rating_value TINYINT unsigned NOT NULL |
33 | 33 | ) /*$wgDBTableOptions*/; |
34 | 34 | |
Index: trunk/extensions/Reviews/includes/Review.php |
— | — | @@ -110,9 +110,15 @@ |
111 | 111 | $success = parent::insertIntoDB(); |
112 | 112 | |
113 | 113 | if ( $success && $this->ratings !== false ) { |
| 114 | + $dbw = wfGetDB( DB_MASTER ); |
| 115 | + $dbw->begin(); |
| 116 | + |
114 | 117 | foreach ( $this->getRatings() as /* ReviewRating */ $rating ) { |
| 118 | + $rating->setField( 'review_id', $this->getId() ); |
115 | 119 | $rating->writeToDB(); |
116 | 120 | } |
| 121 | + |
| 122 | + $dbw->commit(); |
117 | 123 | } |
118 | 124 | |
119 | 125 | return $success; |
— | — | @@ -133,11 +139,19 @@ |
134 | 140 | $existing[$rating->getField( 'type' )] = $rating->getField( 'id' ); |
135 | 141 | } |
136 | 142 | |
| 143 | + $dbw = wfGetDB( DB_MASTER ); |
| 144 | + $dbw->begin(); |
| 145 | + |
137 | 146 | foreach ( $this->getRatings() as /* ReviewRating */ $rating ) { |
138 | 147 | if ( array_key_exists( $rating->getField( 'type' ), $existing ) ) { |
139 | 148 | $rating->setField( 'id', $existing[$rating->getField( 'type' )] ); |
140 | 149 | } |
| 150 | + |
| 151 | + $rating->setField( 'review_id', $this->getId() ); |
| 152 | + $rating->writeToDB(); |
141 | 153 | } |
| 154 | + |
| 155 | + $dbw->commit(); |
142 | 156 | } |
143 | 157 | |
144 | 158 | return $success; |
— | — | @@ -194,7 +208,7 @@ |
195 | 209 | foreach ( $ratings as $type => $value ) { |
196 | 210 | $objects[] = new ReviewRating( array( |
197 | 211 | 'type' => $type, |
198 | | - 'id' => $value |
| 212 | + 'value' => $value |
199 | 213 | ) ); |
200 | 214 | } |
201 | 215 | |
Index: trunk/extensions/Reviews/includes/ReviewRating.php |
— | — | @@ -47,7 +47,7 @@ |
48 | 48 | 'id' => 'id', |
49 | 49 | 'review_id' => 'int', |
50 | 50 | |
51 | | - 'type' => 'int', |
| 51 | + 'type' => 'str', |
52 | 52 | 'value' => 'int' |
53 | 53 | ); |
54 | 54 | } |