Code Duplication    Length = 21-21 lines in 2 locations

model/base.php 2 locations

@@ 206-226 (lines=21) @@
203
		return $models;
204
	}
205
206
	public static function find_one_by_property( $property, $value ) {
207
		global $wpdb;
208
		
209
		$class = get_called_class();
210
		$model = new $class();
211
		$model->flag_as_not_new();
212
		
213
		$row = $wpdb->get_row(
214
			'SELECT * FROM ' . static::table_name() . ' WHERE ' . $property .  ' = \'' . $value . '\' LIMIT 0,1'
215
		);
216
		
217
		if ( ! $row ) {
218
			return NULL;
219
		}
220
		
221
		foreach ( $row as $property => $value ) {
222
			$model->$property = static::unserialize_property($value);
223
		}
224
		
225
		return $model;
226
	}
227
228
	public static function find_all_by_where( $where ) {
229
		global $wpdb;
@@ 254-274 (lines=21) @@
251
		return $models;
252
	}
253
	
254
	public static function find_one_by_where( $where ) {
255
		global $wpdb;
256
		
257
		$class = get_called_class();
258
		$model = new $class();
259
		$model->flag_as_not_new();
260
		
261
		$row = $wpdb->get_row(
262
			'SELECT * FROM ' . static::table_name() . ' WHERE ' . $where . ' LIMIT 0,1'
263
		);
264
		
265
		if ( ! $row ) {
266
			return NULL;
267
		}
268
		
269
		foreach ( $row as $property => $value ) {
270
			$model->$property = static::unserialize_property($value);
271
		}
272
		
273
		return $model;
274
	}
275
	/**
276
	 * Retrieve all entries from the table.
277
	 *