Completed
Branch old/BUG-7514-7935-7936-price-o... (518ae6)
by
unknown
25:14 queued 22:51
created
core/db_models/EEM_Base.model.php 3 patches
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -437,10 +437,10 @@  discard block
 block discarded – undo
437 437
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
438 438
 	 	$status_array = array();
439 439
 	 	foreach ( $stati as $status ) {
440
-            $status_array[ $status->ID() ] = $status->get('STS_code');
441
-        }
442
-        return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
443
-    }
440
+			$status_array[ $status->ID() ] = $status->get('STS_code');
441
+		}
442
+		return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
443
+	}
444 444
 
445 445
 
446 446
 
@@ -3171,12 +3171,12 @@  discard block
 block discarded – undo
3171 3171
 
3172 3172
 
3173 3173
 	/**
3174
-	*		cycle though array of attendees and create objects out of each item
3175
-	*
3176
-	* 		@access		private
3177
-	* 		@param		array		$rows of results of $wpdb->get_results($query,ARRAY_A)
3178
-	*		@return 	EE_Base_Class[]		array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3179
-	*/
3174
+	 *		cycle though array of attendees and create objects out of each item
3175
+	 *
3176
+	 * 		@access		private
3177
+	 * 		@param		array		$rows of results of $wpdb->get_results($query,ARRAY_A)
3178
+	 *		@return 	EE_Base_Class[]		array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
3179
+	 */
3180 3180
 	protected function _create_objects( $rows = array() ) {
3181 3181
 		$array_of_objects=array();
3182 3182
 		if(empty($rows)){
Please login to merge, or discard this patch.
Spacing   +785 added lines, -785 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * @since 				EE4
24 24
  *
25 25
  */
26
-abstract class EEM_Base extends EE_Base{
26
+abstract class EEM_Base extends EE_Base {
27 27
 
28 28
 	/**
29 29
 	 * Flag to indicate whether the values provided to EEM_Base have already been prepared
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * Flag indicating whether this model has a primary key or not
148 148
 	 * @var boolean
149 149
 	 */
150
-	protected $_has_primary_key_field=null;
150
+	protected $_has_primary_key_field = null;
151 151
 
152 152
 	/**
153 153
 	 *	List of valid operators that can be used for querying.
@@ -195,19 +195,19 @@  discard block
 block discarded – undo
195 195
 	 * operators that work like 'BETWEEN'.  Typically used for datetime calculations, i.e. "BETWEEN '12-1-2011' AND '12-31-2012'"
196 196
 	 * @var array
197 197
 	 */
198
-	protected $_between_style_operators = array( 'BETWEEN' );
198
+	protected $_between_style_operators = array('BETWEEN');
199 199
 
200 200
 	/**
201 201
 	 * operators that are used for handling NUll and !NULL queries.  Typically used for when checking if a row exists on a join table.
202 202
 	 * @var array
203 203
 	 */
204
-	protected $_null_style_operators = array( 'IS NOT NULL', 'IS NULL');
204
+	protected $_null_style_operators = array('IS NOT NULL', 'IS NULL');
205 205
 
206 206
 	/**
207 207
 	 * Allowed values for $query_params['order'] for ordering in queries
208 208
 	 * @var array
209 209
 	 */
210
-	protected $_allowed_order_values = array('asc','desc','ASC','DESC');
210
+	protected $_allowed_order_values = array('asc', 'desc', 'ASC', 'DESC');
211 211
 
212 212
 	/**
213 213
 	 * When these are keys in a WHERE or HAVING clause, they are handled much differently
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
 	 * 'where', but 'where' clauses are so common that we thought we'd omit it
222 222
 	 * @var array
223 223
 	 */
224
-	private $_allowed_query_params = array(0, 'limit','order_by','group_by','having','force_join','order','on_join_limit','default_where_conditions');
224
+	private $_allowed_query_params = array(0, 'limit', 'order_by', 'group_by', 'having', 'force_join', 'order', 'on_join_limit', 'default_where_conditions');
225 225
 
226 226
 	/**
227 227
 	 * All the data types that can be used in $wpdb->prepare statements.
228 228
 	 * @var array
229 229
 	 */
230
-	private $_valid_wpdb_data_types = array('%d','%s','%f');
230
+	private $_valid_wpdb_data_types = array('%d', '%s', '%f');
231 231
 
232 232
 	/**
233 233
 	 * 	EE_Registry Object
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
 	 * @param null $timezone
286 286
 	 * @throws \EE_Error
287 287
 	 */
288
-	protected function __construct( $timezone = NULL ){
288
+	protected function __construct($timezone = NULL) {
289 289
 		// check that the model has not been loaded too soon
290
-		if ( ! did_action( 'AHEE__EE_System__load_espresso_addons' )) {
291
-			throw new EE_Error (
290
+		if ( ! did_action('AHEE__EE_System__load_espresso_addons')) {
291
+			throw new EE_Error(
292 292
 				sprintf(
293
-					__( 'The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso' ),
294
-					get_class( $this )
293
+					__('The %1$s model can not be loaded before the "AHEE__EE_System__load_espresso_addons" hook has been called. This gives other addons a chance to extend this model.', 'event_espresso'),
294
+					get_class($this)
295 295
 				)
296 296
 			);
297 297
 		}		/**
@@ -299,11 +299,11 @@  discard block
 block discarded – undo
299 299
 		 * just use EE_Register_Model_Extension
300 300
 		 * @var EE_Table_Base[] $_tables
301 301
 		 */
302
-		$this->_tables = apply_filters( 'FHEE__'.get_class($this).'__construct__tables', $this->_tables );
303
-		foreach($this->_tables as $table_alias => $table_obj){
302
+		$this->_tables = apply_filters('FHEE__'.get_class($this).'__construct__tables', $this->_tables);
303
+		foreach ($this->_tables as $table_alias => $table_obj) {
304 304
 			/** @var $table_obj EE_Table_Base */
305 305
 			$table_obj->_construct_finalize_with_alias($table_alias);
306
-			if( $table_obj instanceof EE_Secondary_Table ){
306
+			if ($table_obj instanceof EE_Secondary_Table) {
307 307
 				/** @var $table_obj EE_Secondary_Table */
308 308
 				$table_obj->_construct_finalize_set_table_to_join_with($this->_get_main_table());
309 309
 			}
@@ -313,48 +313,48 @@  discard block
 block discarded – undo
313 313
 		 * EE_Register_Model_Extension
314 314
 		 * @param EE_Model_Field_Base[] $_fields
315 315
 		 */
316
-		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields',$this->_fields);
317
-		foreach($this->_fields as $table_alias => $fields_for_table){
318
-			if ( ! array_key_exists( $table_alias, $this->_tables )){
319
-				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s",'event_espresso'),$table_alias,implode(",",$this->_fields)));
316
+		$this->_fields = apply_filters('FHEE__'.get_class($this).'__construct__fields', $this->_fields);
317
+		foreach ($this->_fields as $table_alias => $fields_for_table) {
318
+			if ( ! array_key_exists($table_alias, $this->_tables)) {
319
+				throw new EE_Error(sprintf(__("Table alias %s does not exist in EEM_Base child's _tables array. Only tables defined are %s", 'event_espresso'), $table_alias, implode(",", $this->_fields)));
320 320
 			}
321
-			foreach($fields_for_table as $field_name => $field_obj){
321
+			foreach ($fields_for_table as $field_name => $field_obj) {
322 322
 				/** @var $field_obj EE_Model_Field_Base | EE_Primary_Key_Field_Base */
323 323
 				//primary key field base has a slightly different _construct_finalize
324 324
 				/** @var $field_obj EE_Model_Field_Base */
325
-				$field_obj->_construct_finalize( $table_alias, $field_name, $this->get_this_model_name() );
325
+				$field_obj->_construct_finalize($table_alias, $field_name, $this->get_this_model_name());
326 326
 			}
327 327
 		}
328 328
 
329 329
 		// everything is related to Extra_Meta
330
-		if( get_class($this) != 'EEM_Extra_Meta'){
330
+		if (get_class($this) != 'EEM_Extra_Meta') {
331 331
 			//make extra meta related to everything, but don't block deleting things just
332 332
 			//because they have related extra meta info. For now just orphan those extra meta
333 333
 			//in the future we should automatically delete them
334
-			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation( FALSE );
334
+			$this->_model_relations['Extra_Meta'] = new EE_Has_Many_Any_Relation(FALSE);
335 335
 		}
336 336
 		//and change logs
337
-		if( get_class( $this) !=  'EEM_Change_Log' ) {
338
-			$this->_model_relations[ 'Change_Log' ] = new EE_Has_Many_Any_Relation( FALSE );
337
+		if (get_class($this) != 'EEM_Change_Log') {
338
+			$this->_model_relations['Change_Log'] = new EE_Has_Many_Any_Relation(FALSE);
339 339
 		}
340 340
 		/**
341 341
 		 * Filters the list of relations on a model. It is best to NOT use this directly and instead just use
342 342
 		 * EE_Register_Model_Extension
343 343
 		 * @param EE_Model_Relation_Base[] $_model_relations
344 344
 		 */
345
-		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations',$this->_model_relations);
346
-		foreach($this->_model_relations as $model_name => $relation_obj){
345
+		$this->_model_relations = apply_filters('FHEE__'.get_class($this).'__construct__model_relations', $this->_model_relations);
346
+		foreach ($this->_model_relations as $model_name => $relation_obj) {
347 347
 			/** @var $relation_obj EE_Model_Relation_Base */
348 348
 			$relation_obj->_construct_finalize_set_models($this->get_this_model_name(), $model_name);
349 349
 		}
350
-		foreach($this->_indexes as $index_name => $index_obj){
350
+		foreach ($this->_indexes as $index_name => $index_obj) {
351 351
 			/** @var $index_obj EE_Index */
352 352
 			$index_obj->_construct_finalize($index_name, $this->get_this_model_name());
353 353
 		}
354 354
 
355 355
 		$this->set_timezone($timezone);
356 356
 		//finalize default where condition strategy, or set default
357
-		if( ! $this->_default_where_conditions_strategy){
357
+		if ( ! $this->_default_where_conditions_strategy) {
358 358
 			//nothing was set during child constructor, so set default
359 359
 			$this->_default_where_conditions_strategy = new EE_Default_Where_Conditions();
360 360
 		}
@@ -370,20 +370,20 @@  discard block
 block discarded – undo
370 370
 	 * This sets the _timezone property after model object has been instantiated.
371 371
 	 * @param string $timezone valid PHP DateTimeZone timezone string
372 372
 	 */
373
-	public function set_timezone( $timezone ) {
374
-		if($timezone !== NULL){
373
+	public function set_timezone($timezone) {
374
+		if ($timezone !== NULL) {
375 375
 			$this->_timezone = $timezone;
376 376
 		}
377 377
 
378 378
 		//note we need to loop through relations and set the timezone on those objects as well.
379
-		foreach ( $this->_model_relations as $relation ) {
379
+		foreach ($this->_model_relations as $relation) {
380 380
 			$relation->set_timezone($timezone);
381 381
 		}
382 382
 
383 383
 		//and finally we do the same for any datetime fields
384
-		foreach ( $this->_fields as $field ) {
385
-			if ( $field instanceof EE_Datetime_Field ) {
386
-				$field->set_timezone( $timezone );
384
+		foreach ($this->_fields as $field) {
385
+			if ($field instanceof EE_Datetime_Field) {
386
+				$field->set_timezone($timezone);
387 387
 			}
388 388
 		}
389 389
 	}
@@ -395,16 +395,16 @@  discard block
 block discarded – undo
395 395
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
396 396
 	 *		@return static (as in the concrete child class)
397 397
 	 */
398
-	public static function instance( $timezone = NULL ){
398
+	public static function instance($timezone = NULL) {
399 399
 
400 400
 		// check if instance of Espresso_model already exists
401 401
 		if ( ! static::$_instance instanceof static) {
402 402
 			// instantiate Espresso_model
403
-			static::$_instance = new static( $timezone );
403
+			static::$_instance = new static($timezone);
404 404
 		}
405 405
 
406 406
 		//we might have a timezone set, let set_timezone decide what to do with it
407
-		static::$_instance->set_timezone( $timezone );
407
+		static::$_instance->set_timezone($timezone);
408 408
 
409 409
 		// Espresso_model object
410 410
 		return static::$_instance;
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
 	 * resets the model and returns it
417 417
 	 * @return static
418 418
 	 */
419
-	public static function reset(  $timezone = NULL ){
419
+	public static function reset($timezone = NULL) {
420 420
 		static::$_instance = NULL;
421
-		return self::instance( $timezone );
421
+		return self::instance($timezone);
422 422
 	}
423 423
 
424 424
 
@@ -429,15 +429,15 @@  discard block
 block discarded – undo
429 429
 	 * @param  boolean $translated return localized strings or JUST the array.
430 430
 	 * @return array
431 431
 	 */
432
-	 public function status_array( $translated = FALSE ) {
433
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
432
+	 public function status_array($translated = FALSE) {
433
+	 	if ( ! array_key_exists('Status', $this->_model_relations))
434 434
 	 		return array();
435 435
 	 	$model_name = $this->get_this_model_name();
436
-	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
437
-	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
436
+	 	$status_type = str_replace(' ', '_', strtolower(str_replace('_', ' ', $model_name)));
437
+	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type)));
438 438
 	 	$status_array = array();
439
-	 	foreach ( $stati as $status ) {
440
-            $status_array[ $status->ID() ] = $status->get('STS_code');
439
+	 	foreach ($stati as $status) {
440
+            $status_array[$status->ID()] = $status->get('STS_code');
441 441
         }
442 442
         return $translated ? EEM_Status::instance()->localized_status($status_array, FALSE, 'sentence') : $status_array;
443 443
     }
@@ -574,7 +574,7 @@  discard block
 block discarded – undo
574 574
 	 *			'order_by'=>array('ANS_value'=>'ASC')
575 575
 	 *		));
576 576
 	 */
577
-	function get_all($query_params = array()){
577
+	function get_all($query_params = array()) {
578 578
 		return $this->_create_objects($this->_get_all_wpdb_results($query_params, ARRAY_A, NULL));
579 579
 	}
580 580
 
@@ -584,21 +584,21 @@  discard block
 block discarded – undo
584 584
 	 * @param array $query_parms @see EEM_Base::get_all()
585 585
 	 * @return array like EEM_Base::get_all
586 586
 	 */
587
-	function alter_query_params_to_only_include_mine( $query_parms = array() ) {
587
+	function alter_query_params_to_only_include_mine($query_parms = array()) {
588 588
 		try {
589
-			if( ! empty( $this->_model_chain_to_wp_user ) ) {
590
-				$models_to_follow_to_wp_users = explode( '.', $this->_model_chain_to_wp_user );
591
-				$last_model_name = end( $models_to_follow_to_wp_users );
592
-				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
593
-				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
594
-			}else{
589
+			if ( ! empty($this->_model_chain_to_wp_user)) {
590
+				$models_to_follow_to_wp_users = explode('.', $this->_model_chain_to_wp_user);
591
+				$last_model_name = end($models_to_follow_to_wp_users);
592
+				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model($last_model_name);
593
+				$model_chain_to_wp_user = $this->_model_chain_to_wp_user.'.';
594
+			} else {
595 595
 				$model_with_fk_to_wp_users = $this;
596 596
 				$model_chain_to_wp_user = '';
597 597
 			}
598
-			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to( 'WP_User' );
599
-			$query_parms[0][ $model_chain_to_wp_user . $wp_user_field->get_name() ] = get_current_user_id();
598
+			$wp_user_field = $model_with_fk_to_wp_users->get_foreign_key_to('WP_User');
599
+			$query_parms[0][$model_chain_to_wp_user.$wp_user_field->get_name()] = get_current_user_id();
600 600
 			return $query_parms;
601
-		} catch( EE_Error $e ) {
601
+		} catch (EE_Error $e) {
602 602
 			//if there's no foreign key to WP_User, then they own all of them?
603 603
 			return $query_parms;
604 604
 		}
@@ -613,7 +613,7 @@  discard block
 block discarded – undo
613 613
 	 * (or transietly-related model)
614 614
 	 * @return string
615 615
 	 */
616
-	public function model_chain_to_wp_user(){
616
+	public function model_chain_to_wp_user() {
617 617
 		return $this->_model_chain_to_wp_user;
618 618
 	}
619 619
 
@@ -625,13 +625,13 @@  discard block
 block discarded – undo
625 625
 	 * @return boolean
626 626
 	 */
627 627
 	public function is_owned() {
628
-		if( $this->model_chain_to_wp_user() ){
628
+		if ($this->model_chain_to_wp_user()) {
629 629
 			return true;
630
-		}else{
631
-			try{
632
-				$this->get_foreign_key_to( 'WP_User' );
630
+		} else {
631
+			try {
632
+				$this->get_foreign_key_to('WP_User');
633 633
 				return true;
634
-			}catch( EE_Error $e ){
634
+			} catch (EE_Error $e) {
635 635
 				return false;
636 636
 			}
637 637
 		}
@@ -650,21 +650,21 @@  discard block
 block discarded – undo
650 650
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
651 651
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
652 652
 	 */
653
-	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
653
+	protected function  _get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
654 654
 		//remember the custom selections, if any
655
-		if(is_array($columns_to_select)){
655
+		if (is_array($columns_to_select)) {
656 656
 			$this->_custom_selections = $columns_to_select;
657
-		}elseif(is_string($columns_to_select)){
657
+		}elseif (is_string($columns_to_select)) {
658 658
 			$this->_custom_selections = array($this->_custom_selections);
659
-		}else{
659
+		} else {
660 660
 			$this->_custom_selections = array();
661 661
 		}
662 662
 
663 663
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
664 664
 		$select_expressions = $columns_to_select ? $this->_construct_select_from_input($columns_to_select) : $this->_construct_default_select_sql($model_query_info);
665
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
665
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
666 666
 //		echo "sql:$SQL";
667
-		$results =  $this->_do_wpdb_query( 'get_results', array($SQL, $output ) );// $wpdb->get_results($SQL, $output);
667
+		$results = $this->_do_wpdb_query('get_results', array($SQL, $output)); // $wpdb->get_results($SQL, $output);
668 668
 		return $results;
669 669
 	}
670 670
 
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 	 * and 1 is the data type. Eg, array('count'=>array('COUNT(REG_ID)','%d'))
682 682
 	 * @return stdClass[] like results of $wpdb->get_results($sql,OBJECT), (ie, output type is OBJECT)
683 683
 	 */
684
-	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null){
684
+	public function  get_all_wpdb_results($query_params = array(), $output = ARRAY_A, $columns_to_select = null) {
685 685
 		return $this->_get_all_wpdb_results($query_params, $output, $columns_to_select);
686 686
 	}
687 687
 
@@ -693,21 +693,21 @@  discard block
 block discarded – undo
693 693
 	 * @throws EE_Error
694 694
 	 * @return string
695 695
 	 */
696
-	private function _construct_select_from_input($columns_to_select){
697
-		if(is_array($columns_to_select)){
696
+	private function _construct_select_from_input($columns_to_select) {
697
+		if (is_array($columns_to_select)) {
698 698
 			$select_sql_array = array();
699 699
 
700
-			foreach($columns_to_select as $alias => $selection_and_datatype){
701
-				if( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])){
702
-					throw new EE_Error(sprintf(__("Custom selection %s (alias %s) needs to be an array like array('COUNT(REG_ID)','%%d')", "event_espresso"),$selection_and_datatype,$alias));
700
+			foreach ($columns_to_select as $alias => $selection_and_datatype) {
701
+				if ( ! is_array($selection_and_datatype) || ! isset($selection_and_datatype[1])) {
702
+					throw new EE_Error(sprintf(__("Custom selection %s (alias %s) needs to be an array like array('COUNT(REG_ID)','%%d')", "event_espresso"), $selection_and_datatype, $alias));
703 703
 				}
704
-				if( ! in_array( $selection_and_datatype[1],$this->_valid_wpdb_data_types)){
705
-					throw new EE_Error(sprintf(__("Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", "event_espresso"),$selection_and_datatype[1],$selection_and_datatype[0],$alias,implode(",",$this->_valid_wpdb_data_types)));
704
+				if ( ! in_array($selection_and_datatype[1], $this->_valid_wpdb_data_types)) {
705
+					throw new EE_Error(sprintf(__("Datatype %s (for selection '%s' and alias '%s') is not a valid wpdb datatype (eg %%s)", "event_espresso"), $selection_and_datatype[1], $selection_and_datatype[0], $alias, implode(",", $this->_valid_wpdb_data_types)));
706 706
 				}
707 707
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
708 708
 			}
709
-			$columns_to_select_string = implode(", ",$select_sql_array);
710
-		}else{
709
+			$columns_to_select_string = implode(", ", $select_sql_array);
710
+		} else {
711 711
 			$columns_to_select_string = $columns_to_select;
712 712
 		}
713 713
 		return $columns_to_select_string;
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 	 * Convenient wrapper for getting the primary key field's name. Eg, on Registration, this would be 'REG_ID'
721 721
 	 * @return string
722 722
 	 */
723
-	function primary_key_name(){
723
+	function primary_key_name() {
724 724
 		return $this->get_primary_key_field()->get_name();
725 725
 	}
726 726
 
@@ -732,15 +732,15 @@  discard block
 block discarded – undo
732 732
 	 * @param mixed $id int or string, depending on the type of the model's primary key
733 733
 	 * @return EE_Base_Class
734 734
 	 */
735
-	function get_one_by_ID($id){
736
-		if( $this->get_from_entity_map( $id ) ){
737
-			return $this->get_from_entity_map( $id );
738
-		}elseif( $this->has_primary_key_field ( ) ) {
735
+	function get_one_by_ID($id) {
736
+		if ($this->get_from_entity_map($id)) {
737
+			return $this->get_from_entity_map($id);
738
+		}elseif ($this->has_primary_key_field( )) {
739 739
 			$primary_key_name = $this->get_primary_key_field()->get_name();
740 740
 			return $this->get_one(array(array($primary_key_name => $id)));
741
-		}else{
741
+		} else {
742 742
 			//no primary key, so the $id must be from the get_index_primary_key_string()
743
-			return $this->get_one( array( $this->parse_index_primary_key_string( $id ) ) );
743
+			return $this->get_one(array($this->parse_index_primary_key_string($id)));
744 744
 		}
745 745
 	}
746 746
 
@@ -751,16 +751,16 @@  discard block
 block discarded – undo
751 751
 	 * @param array $query_params like EEM_Base's $query_params variable.
752 752
 	 * @return EE_Base_Class | NULL
753 753
 	 */
754
-	function get_one($query_params = array()){
755
-		if( ! is_array( $query_params ) ){
756
-			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
754
+	function get_one($query_params = array()) {
755
+		if ( ! is_array($query_params)) {
756
+			EE_Error::doing_it_wrong('EEM_Base::get_one', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
757 757
 			$query_params = array();
758 758
 		}
759 759
 		$query_params['limit'] = 1;
760 760
 		$items = $this->get_all($query_params);
761
-		if(empty($items)){
761
+		if (empty($items)) {
762 762
 			return null;
763
-		}else{
763
+		} else {
764 764
 			return array_shift($items);
765 765
 		}
766 766
 	}
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 	 * Gets all the tables comprising this model. Array keys are the table aliases, and values are EE_Table objects
784 784
 	 * @return EE_Table_Base[]
785 785
 	 */
786
-	function get_tables(){
786
+	function get_tables() {
787 787
 		return $this->_tables;
788 788
 	}
789 789
 
@@ -817,9 +817,9 @@  discard block
 block discarded – undo
817 817
 	 * be aware that model objects being used could get out-of-sync with the database
818 818
 	 * @return int how many rows got updated or FALSE if something went wrong with the query (wp returns FALSE or num rows affected which *could* include 0 which DOES NOT mean the query was bad)
819 819
 	 */
820
-	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE){
821
-		if( ! is_array( $query_params ) ){
822
-			EE_Error::doing_it_wrong('EEM_Base::update', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
820
+	function update($fields_n_values, $query_params, $keep_model_objs_in_sync = TRUE) {
821
+		if ( ! is_array($query_params)) {
822
+			EE_Error::doing_it_wrong('EEM_Base::update', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
823 823
 			$query_params = array();
824 824
 		}
825 825
 		/**
@@ -829,7 +829,7 @@  discard block
 block discarded – undo
829 829
 		 * @param array $fields_n_values the updated fields and their new values
830 830
 		 * @param array $query_params @see EEM_Base::get_all()
831 831
 		 */
832
-		do_action( 'AHEE__EEM_Base__update__begin',$this, $fields_n_values, $query_params );
832
+		do_action('AHEE__EEM_Base__update__begin', $this, $fields_n_values, $query_params);
833 833
 		/**
834 834
 		 * Filters the fields about to be updated given the query parameters. You can provide the
835 835
 		 * $query_params to $this->get_all() to find exactly which records will be updated
@@ -837,10 +837,10 @@  discard block
 block discarded – undo
837 837
 		 * @param EEM_Base $model the model being queried
838 838
 		 * @param array $query_params see EEM_Base::get_all()
839 839
 		 */
840
-		$fields_n_values = apply_filters( 'FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params );
840
+		$fields_n_values = apply_filters('FHEE__EEM_Base__update__fields_n_values', $fields_n_values, $this, $query_params);
841 841
 		//need to verify that, for any entry we want to update, there are entries in each secondary table.
842 842
 		//to do that, for each table, verify that it's PK isn't null.
843
-		$tables= $this->get_tables();
843
+		$tables = $this->get_tables();
844 844
 
845 845
 		//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
846 846
 		//NOTE: we should make this code more efficient by NOT querying twice
@@ -850,26 +850,26 @@  discard block
 block discarded – undo
850 850
 			//we want to make sure the default_where strategy is ignored
851 851
 			$this->_ignore_where_strategy = TRUE;
852 852
 			$wpdb_select_results = $this->_get_all_wpdb_results($query_params);
853
-			foreach( $wpdb_select_results as $wpdb_result ){
853
+			foreach ($wpdb_select_results as $wpdb_result) {
854 854
 				// type cast stdClass as array
855
-				$wpdb_result = (array)$wpdb_result;
855
+				$wpdb_result = (array) $wpdb_result;
856 856
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
857
-				if( $this->has_primary_key_field() ){
858
-					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
859
-				}else{
857
+				if ($this->has_primary_key_field()) {
858
+					$main_table_pk_value = $wpdb_result[$this->get_primary_key_field()->get_qualified_column()];
859
+				} else {
860 860
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it woudl be lots of work)
861 861
 					$main_table_pk_value = null;
862 862
 				}
863 863
 				//if there are more than 1 tables, we'll want to verify that each table for this model has an entry in the other tables
864 864
 				//and if the other tables don't have a row for each table-to-be-updated, we'll insert one with whatever values available in the current update query
865
-				if(count($tables) > 1){
865
+				if (count($tables) > 1) {
866 866
 					//foreach matching row in the DB, ensure that each table's PK isn't null. If so, there must not be an entry
867 867
 					//in that table, and so we'll want to insert one
868
-					foreach($tables as $table_obj){
868
+					foreach ($tables as $table_obj) {
869 869
 						$this_table_pk_column = $table_obj->get_fully_qualified_pk_column();
870 870
 						//if there is no private key for this table on the results, it means there's no entry
871 871
 						//in this table, right? so insert a row in the current table, using any fields available
872
-						if( ! ( array_key_exists( $this_table_pk_column, $wpdb_result) && $wpdb_result[ $this_table_pk_column ] )){
872
+						if ( ! (array_key_exists($this_table_pk_column, $wpdb_result) && $wpdb_result[$this_table_pk_column])) {
873 873
 							$this->_insert_into_specific_table($table_obj, $fields_n_values, $main_table_pk_value);
874 874
 						}
875 875
 					}
@@ -888,44 +888,44 @@  discard block
 block discarded – undo
888 888
 		//if this wasn't called from a model object (to update itself)
889 889
 		//then we want to make sure we keep all the existing
890 890
 		//model objects in sync with the db
891
-		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
892
-			if( $this->has_primary_key_field() ){
893
-				$model_objs_affected_ids = $this->get_col( $query_params );
894
-			}else{
891
+		if ($keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object) {
892
+			if ($this->has_primary_key_field()) {
893
+				$model_objs_affected_ids = $this->get_col($query_params);
894
+			} else {
895 895
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
896
-				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
896
+				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A);
897 897
 				$model_objs_affected_ids = array();
898
-				foreach( $models_affected_key_columns as $row ){
899
-					$combined_index_key = $this->get_index_primary_key_string( $row );
900
-					$model_objs_affected_ids[ $combined_index_key ] = $combined_index_key;
898
+				foreach ($models_affected_key_columns as $row) {
899
+					$combined_index_key = $this->get_index_primary_key_string($row);
900
+					$model_objs_affected_ids[$combined_index_key] = $combined_index_key;
901 901
 				}
902 902
 
903 903
 			}
904 904
 
905
-			if( ! $model_objs_affected_ids ){
905
+			if ( ! $model_objs_affected_ids) {
906 906
 				//wait wait wait- if nothing was affected let's stop here
907 907
 				return 0;
908 908
 			}
909
-			foreach( $model_objs_affected_ids as $id ){
910
-				$model_obj_in_entity_map = $this->get_from_entity_map( $id );
911
-				if( $model_obj_in_entity_map ){
912
-					foreach( $fields_n_values as $field => $new_value ){
913
-						$model_obj_in_entity_map->set( $field, $new_value );
909
+			foreach ($model_objs_affected_ids as $id) {
910
+				$model_obj_in_entity_map = $this->get_from_entity_map($id);
911
+				if ($model_obj_in_entity_map) {
912
+					foreach ($fields_n_values as $field => $new_value) {
913
+						$model_obj_in_entity_map->set($field, $new_value);
914 914
 					}
915 915
 				}
916 916
 			}
917 917
 			//if there is a primary key on this model, we can now do a slight optimization
918
-			if( $this->has_primary_key_field() ){
918
+			if ($this->has_primary_key_field()) {
919 919
 				//we already know what we want to update. So let's make the query simpler so it's a little more efficient
920 920
 				$query_params = array(
921
-					array( $this->primary_key_name() => array( 'IN', $model_objs_affected_ids ) ),
922
-					'limit' => count( $model_objs_affected_ids ), 'default_where_conditions' => 'none' );
921
+					array($this->primary_key_name() => array('IN', $model_objs_affected_ids)),
922
+					'limit' => count($model_objs_affected_ids), 'default_where_conditions' => 'none' );
923 923
 			}
924 924
 		}
925 925
 
926
-		$model_query_info = $this->_create_model_query_info_carrier( $query_params );
927
-		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql();//note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
928
-		$rows_affected = $this->_do_wpdb_query('query', array( $SQL ) );
926
+		$model_query_info = $this->_create_model_query_info_carrier($query_params);
927
+		$SQL = "UPDATE ".$model_query_info->get_full_join_sql()." SET ".$this->_construct_update_sql($fields_n_values).$model_query_info->get_where_sql(); //note: doesn't use _construct_2nd_half_of_select_query() because doesn't accept LIMIT, ORDER BY, etc.
928
+		$rows_affected = $this->_do_wpdb_query('query', array($SQL));
929 929
 		/**
930 930
 		 * Action called after a model update call has been made.
931 931
 		 *
@@ -934,8 +934,8 @@  discard block
 block discarded – undo
934 934
 		 * @param array $query_params @see EEM_Base::get_all()
935 935
 		 * @param int $rows_affected
936 936
 		 */
937
-		do_action( 'AHEE__EEM_Base__update__end',$this, $fields_n_values, $query_params, $rows_affected );
938
-		return $rows_affected;//how many supposedly got updated
937
+		do_action('AHEE__EEM_Base__update__end', $this, $fields_n_values, $query_params, $rows_affected);
938
+		return $rows_affected; //how many supposedly got updated
939 939
 	}
940 940
 
941 941
 	/**
@@ -947,22 +947,22 @@  discard block
 block discarded – undo
947 947
 	 * @param string $field_to_select
948 948
 	 * @return array just like $wpdb->get_col()
949 949
 	 */
950
-	public function get_col( $query_params  = array(), $field_to_select = NULL ){
950
+	public function get_col($query_params = array(), $field_to_select = NULL) {
951 951
 
952
-		if( $field_to_select ){
953
-			$field = $this->field_settings_for( $field_to_select );
954
-		}elseif( $this->has_primary_key_field ( ) ){
952
+		if ($field_to_select) {
953
+			$field = $this->field_settings_for($field_to_select);
954
+		}elseif ($this->has_primary_key_field( )) {
955 955
 			$field = $this->get_primary_key_field();
956
-		}else{
956
+		} else {
957 957
 			//no primary key, just grab the first column
958
-			$field = reset( $this->field_settings());
958
+			$field = reset($this->field_settings());
959 959
 		}
960 960
 
961 961
 
962 962
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
963 963
 		$select_expressions = $field->get_qualified_column();
964
-		$SQL ="SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
965
-		$results =  $this->_do_wpdb_query('get_col', array( $SQL ) );
964
+		$SQL = "SELECT $select_expressions ".$this->_construct_2nd_half_of_select_query($model_query_info);
965
+		$results = $this->_do_wpdb_query('get_col', array($SQL));
966 966
 		return $results;
967 967
 	}
968 968
 
@@ -975,18 +975,18 @@  discard block
 block discarded – undo
975 975
 	 * @param array $fields_n_values array keys are field names on this model, and values are what those fields should be updated to in the DB
976 976
 	 * @return string of SQL
977 977
 	 */
978
-	function _construct_update_sql($fields_n_values){
978
+	function _construct_update_sql($fields_n_values) {
979 979
 		global $wpdb;
980 980
 		$cols_n_values = array();
981
-		foreach($fields_n_values as $field_name => $value){
981
+		foreach ($fields_n_values as $field_name => $value) {
982 982
 			$field_obj = $this->field_settings_for($field_name);
983 983
 			//if the value is NULL, we want to assign the value to that.
984 984
 			//wpdb->prepare doesn't really handle that properly
985
-			$prepared_value = $this->_prepare_value_or_use_default( $field_obj, $fields_n_values );
986
-			$value_sql = $prepared_value===NULL ? 'NULL' : $wpdb->prepare( $field_obj->get_wpdb_data_type(), $prepared_value );
985
+			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
986
+			$value_sql = $prepared_value === NULL ? 'NULL' : $wpdb->prepare($field_obj->get_wpdb_data_type(), $prepared_value);
987 987
 			$cols_n_values[] = $field_obj->get_qualified_column()."=".$value_sql;
988 988
 		}
989
-		return implode(",",$cols_n_values);
989
+		return implode(",", $cols_n_values);
990 990
 
991 991
 	}
992 992
 
@@ -998,11 +998,11 @@  discard block
 block discarded – undo
998 998
 	 * @param mixed $id
999 999
 	 * @return boolean whether the row got deleted or not
1000 1000
 	 */
1001
-	public function delete_by_ID( $id ){
1002
-		return $this->delete( array(
1003
-			array( $this->get_primary_key_field()->get_name() => $id ),
1001
+	public function delete_by_ID($id) {
1002
+		return $this->delete(array(
1003
+			array($this->get_primary_key_field()->get_name() => $id),
1004 1004
 			'limit' 	=> 1
1005
-		) );
1005
+		));
1006 1006
 	}
1007 1007
 
1008 1008
 
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
 	 * which may depend on it. Its generally advisable to always leave this as TRUE, otherwise you could easily corrupt your DB
1018 1018
 	 * @return int how many rows got deleted
1019 1019
 	 */
1020
-	function delete($query_params,$allow_blocking = true){
1020
+	function delete($query_params, $allow_blocking = true) {
1021 1021
 		/**
1022 1022
 		 * Action called just before performing a real deletion query. You can use the
1023 1023
 		 * model and its $query_params to find exactly which items will be deleted
@@ -1026,34 +1026,34 @@  discard block
 block discarded – undo
1026 1026
 		 * @param boolean $allow_blocking whether or not to allow related model objects
1027 1027
 		 * to block (prevent) this deletion
1028 1028
 		 */
1029
-		do_action( 'AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking );
1029
+		do_action('AHEE__EEM_Base__delete__begin', $this, $query_params, $allow_blocking);
1030 1030
 		//some MySQL databases may be running safe mode, which may restrict
1031 1031
 		//deletion if there is no KEY column used in the WHERE statement of a deletion.
1032 1032
 		//to get around this, we first do a SELECT, get all the IDs, and then run another query
1033 1033
 		//to delete them
1034 1034
 		$items_for_deletion = $this->_get_all_wpdb_results($query_params);
1035
-		$deletion_where = $this->_setup_ids_for_delete( $items_for_deletion, $allow_blocking);
1036
-		if($deletion_where){
1035
+		$deletion_where = $this->_setup_ids_for_delete($items_for_deletion, $allow_blocking);
1036
+		if ($deletion_where) {
1037 1037
 			//echo "objects for deletion:";var_dump($objects_for_deletion);
1038 1038
 			$model_query_info = $this->_create_model_query_info_carrier($query_params);
1039 1039
 			$table_aliases = array();
1040
-			foreach(array_keys($this->_tables) as $table_alias){
1040
+			foreach (array_keys($this->_tables) as $table_alias) {
1041 1041
 				$table_aliases[] = $table_alias;
1042 1042
 			}
1043
-			$SQL = "DELETE ".implode(", ",$table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1043
+			$SQL = "DELETE ".implode(", ", $table_aliases)." FROM ".$model_query_info->get_full_join_sql()." WHERE ".$deletion_where;
1044 1044
 
1045 1045
 			//		/echo "delete sql:$SQL";
1046
-			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1047
-		}else{
1046
+			$rows_deleted = $this->_do_wpdb_query('query', array($SQL));
1047
+		} else {
1048 1048
 			$rows_deleted = 0;
1049 1049
 		}
1050 1050
 
1051 1051
 		//and lastly make sure those items are removed from the entity map; if they could be put into it at all
1052
-		if( $this->has_primary_key_field() ){
1053
-			foreach($items_for_deletion as $item_for_deletion_row ){
1054
-				$pk_value = $item_for_deletion_row[ $this->get_primary_key_field()->get_qualified_column() ];
1055
-				if( isset( $this->_entity_map[ $pk_value ] ) ){
1056
-					unset( $this->_entity_map[ $pk_value ] );
1052
+		if ($this->has_primary_key_field()) {
1053
+			foreach ($items_for_deletion as $item_for_deletion_row) {
1054
+				$pk_value = $item_for_deletion_row[$this->get_primary_key_field()->get_qualified_column()];
1055
+				if (isset($this->_entity_map[$pk_value])) {
1056
+					unset($this->_entity_map[$pk_value]);
1057 1057
 				}
1058 1058
 			}
1059 1059
 		}
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
 		 * @param array $query_params @see EEM_Base::get_all()
1066 1066
 		 * @param int $rows_deleted
1067 1067
 		 */
1068
-		do_action( 'AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted );
1069
-		return $rows_deleted;//how many supposedly got deleted
1068
+		do_action('AHEE__EEM_Base__delete__end', $this, $query_params, $rows_deleted);
1069
+		return $rows_deleted; //how many supposedly got deleted
1070 1070
 	}
1071 1071
 
1072 1072
 
@@ -1082,28 +1082,28 @@  discard block
 block discarded – undo
1082 1082
 	 * blocking its deletion before removing the relation between A and B
1083 1083
 	 * @return boolean
1084 1084
 	 */
1085
-	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null){
1085
+	public function delete_is_blocked_by_related_models($this_model_obj_or_id, $ignore_this_model_obj = null) {
1086 1086
 		//first, if $ignore_this_model_obj was supplied, get its model
1087
-		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1087
+		if ($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class) {
1088 1088
 			$ignored_model = $ignore_this_model_obj->get_model();
1089
-		}else{
1089
+		} else {
1090 1090
 			$ignored_model = null;
1091 1091
 		}
1092 1092
 		//now check all the relations of $this_model_obj_or_id and see if there
1093 1093
 		//are any related model objects blocking it?
1094 1094
 		$is_blocked = false;
1095
-		foreach($this->_model_relations as $relation_name => $relation_obj){
1096
-			if( $relation_obj->block_delete_if_related_models_exist()){
1095
+		foreach ($this->_model_relations as $relation_name => $relation_obj) {
1096
+			if ($relation_obj->block_delete_if_related_models_exist()) {
1097 1097
 				//if $ignore_this_model_obj was supplied, then for the query
1098 1098
 				//on that model needs to be told to ignore $ignore_this_model_obj
1099
-				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1100
-					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1101
-					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1102
-				}else{
1099
+				if ($ignored_model && $relation_name == $ignored_model->get_this_model_name()) {
1100
+					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id, array(
1101
+					array($ignored_model->get_primary_key_field()->get_name() => array('!=', $ignore_this_model_obj->ID()))));
1102
+				} else {
1103 1103
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1104 1104
 				}
1105 1105
 
1106
-				if($related_model_objects){
1106
+				if ($related_model_objects) {
1107 1107
 					EE_Error::add_error($relation_obj->get_deletion_error_message(), __FILE__, __FUNCTION__, __LINE__);
1108 1108
 					$is_blocked = true;
1109 1109
 				}
@@ -1123,65 +1123,65 @@  discard block
 block discarded – undo
1123 1123
 	 * @throws EE_Error
1124 1124
 	 * @return string    everything that comes after the WHERE statement.
1125 1125
 	 */
1126
-	protected function _setup_ids_for_delete( $objects_for_deletion, $allow_blocking = true) {
1127
-		if($this->has_primary_key_field()){
1126
+	protected function _setup_ids_for_delete($objects_for_deletion, $allow_blocking = true) {
1127
+		if ($this->has_primary_key_field()) {
1128 1128
 			$primary_table = $this->_get_main_table();
1129 1129
 			$other_tables = $this->_get_other_tables();
1130 1130
 			$deletes = $query = array();
1131
-			foreach ( $objects_for_deletion as $delete_object ) {
1131
+			foreach ($objects_for_deletion as $delete_object) {
1132 1132
 				//before we mark this object for deletion,
1133 1133
 				//make sure there's no related objects blocking its deletion (if we're checking)
1134
-				if( $allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()]) ){
1134
+				if ($allow_blocking && $this->delete_is_blocked_by_related_models($delete_object[$primary_table->get_fully_qualified_pk_column()])) {
1135 1135
 					continue;
1136 1136
 				}
1137 1137
 
1138 1138
 				//primary table deletes
1139
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1139
+				if (isset($delete_object[$primary_table->get_fully_qualified_pk_column()]))
1140 1140
 					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1141 1141
 
1142 1142
 				//other tables
1143
-				if ( !empty( $other_tables ) ) {
1144
-					foreach ( $other_tables as $ot ) {
1143
+				if ( ! empty($other_tables)) {
1144
+					foreach ($other_tables as $ot) {
1145 1145
 
1146 1146
 						//first check if we've got the foreign key column here.
1147
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1147
+						if (isset($delete_object[$ot->get_fully_qualified_fk_column()]))
1148 1148
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1149 1149
 
1150 1150
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1151
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1151
+						if (isset($delete_object[$ot->get_fully_qualified_pk_column()]))
1152 1152
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1153 1153
 
1154 1154
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1155
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1155
+						if (isset($delete_object[$ot->get_fully_qualified_pk_on_fk_table()]))
1156 1156
 							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1157 1157
 					}
1158 1158
 				}
1159 1159
 			}
1160 1160
 
1161 1161
 			//we should have deletes now, so let's just go through and setup the where statement
1162
-			foreach ( $deletes as $column => $values ) {
1162
+			foreach ($deletes as $column => $values) {
1163 1163
 				//make sure we have unique $values;
1164 1164
 				$values = array_unique($values);
1165
-				$query[] = $column . ' IN(' . implode(",",$values) . ')';
1165
+				$query[] = $column.' IN('.implode(",", $values).')';
1166 1166
 			}
1167 1167
 
1168
-			return !empty($query) ? implode(' AND ', $query ) : '';
1169
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1168
+			return ! empty($query) ? implode(' AND ', $query) : '';
1169
+		}elseif (count($this->get_combined_primary_key_fields()) > 1) {
1170 1170
 			$ways_to_identify_a_row = array();
1171 1171
 			$fields = $this->get_combined_primary_key_fields();
1172 1172
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
1173
-			foreach($objects_for_deletion as  $delete_object){
1173
+			foreach ($objects_for_deletion as  $delete_object) {
1174 1174
 				$values_for_each_cpk_for_a_row = array();
1175
-				foreach($fields as $cpk_field){
1175
+				foreach ($fields as $cpk_field) {
1176 1176
 					$values_for_each_cpk_for_a_row[] = $cpk_field->get_qualified_column()."=".$delete_object[$cpk_field->get_qualified_column()];
1177 1177
 				}
1178
-				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1178
+				$ways_to_identify_a_row[] = "(".implode(" AND ", $values_for_each_cpk_for_a_row).")";
1179 1179
 			}
1180
-			return implode(" OR ",$ways_to_identify_a_row);
1181
-		}else{
1180
+			return implode(" OR ", $ways_to_identify_a_row);
1181
+		} else {
1182 1182
 			//so there's no primary key and no combined key...
1183 1183
 			//sorry, can't help you
1184
-			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
1184
+			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"), get_class($this)));
1185 1185
 		}
1186 1186
 	}
1187 1187
 
@@ -1195,21 +1195,21 @@  discard block
 block discarded – undo
1195 1195
 	 * @param bool 	 $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
1196 1196
 	 * @return int
1197 1197
 	 */
1198
-	function count($query_params =array(),$field_to_count = NULL, $distinct = FALSE){
1198
+	function count($query_params = array(), $field_to_count = NULL, $distinct = FALSE) {
1199 1199
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1200
-		if($field_to_count){
1200
+		if ($field_to_count) {
1201 1201
 			$field_obj = $this->field_settings_for($field_to_count);
1202 1202
 			$column_to_count = $field_obj->get_qualified_column();
1203
-		}elseif($this->has_primary_key_field ()){
1203
+		}elseif ($this->has_primary_key_field()) {
1204 1204
 			$pk_field_obj = $this->get_primary_key_field();
1205 1205
 			$column_to_count = $pk_field_obj->get_qualified_column();
1206
-		}else{//there's no primary key
1206
+		} else {//there's no primary key
1207 1207
 			$column_to_count = '*';
1208 1208
 		}
1209 1209
 
1210
-		$column_to_count = $distinct ? "DISTINCT (" . $column_to_count . " )" : $column_to_count;
1211
-		$SQL ="SELECT COUNT(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1212
-		return (int)$this->_do_wpdb_query( 'get_var', array( $SQL) );
1210
+		$column_to_count = $distinct ? "DISTINCT (".$column_to_count." )" : $column_to_count;
1211
+		$SQL = "SELECT COUNT(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1212
+		return (int) $this->_do_wpdb_query('get_var', array($SQL));
1213 1213
 	}
1214 1214
 
1215 1215
 	/**
@@ -1219,23 +1219,23 @@  discard block
 block discarded – undo
1219 1219
 	 * @param string $field_to_sum name of field (array key in $_fields array)
1220 1220
 	 * @return int
1221 1221
 	 */
1222
-	function sum($query_params, $field_to_sum = NULL){
1222
+	function sum($query_params, $field_to_sum = NULL) {
1223 1223
 		$model_query_info = $this->_create_model_query_info_carrier($query_params);
1224 1224
 
1225
-		if($field_to_sum){
1225
+		if ($field_to_sum) {
1226 1226
 			$field_obj = $this->field_settings_for($field_to_sum);
1227 1227
 
1228
-		}else{
1228
+		} else {
1229 1229
 			$field_obj = $this->get_primary_key_field();
1230 1230
 		}
1231 1231
 		$column_to_count = $field_obj->get_qualified_column();
1232 1232
 
1233
-		$SQL ="SELECT SUM(".$column_to_count.")" . $this->_construct_2nd_half_of_select_query($model_query_info);
1234
-		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1235
-		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1236
-			return (int)$return_value;
1237
-		}else{//must be %f
1238
-			return (float)$return_value;
1233
+		$SQL = "SELECT SUM(".$column_to_count.")".$this->_construct_2nd_half_of_select_query($model_query_info);
1234
+		$return_value = $this->_do_wpdb_query('get_var', array($SQL));
1235
+		if ($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s') {
1236
+			return (int) $return_value;
1237
+		} else {//must be %f
1238
+			return (float) $return_value;
1239 1239
 		}
1240 1240
 	}
1241 1241
 
@@ -1250,29 +1250,29 @@  discard block
 block discarded – undo
1250 1250
 	 * @global wpdb $wpdb
1251 1251
 	 * @return mixed
1252 1252
 	 */
1253
-	protected function _do_wpdb_query( $wpdb_method, $arguments_to_provide ){
1253
+	protected function _do_wpdb_query($wpdb_method, $arguments_to_provide) {
1254 1254
 		//if we're in maintenance mode level 2, DON'T run any queries
1255 1255
 		//because level 2 indicates the database needs updating and
1256 1256
 		//is probably out of sync with the code
1257
-		if( ! EE_Maintenance_Mode::instance()->models_can_query()){
1257
+		if ( ! EE_Maintenance_Mode::instance()->models_can_query()) {
1258 1258
 			throw new EE_Error(sprintf(__("Event Espresso Level 2 Maintenance mode is active. That means EE can not run ANY database queries until the necessary migration scripts have run which will take EE out of maintenance mode level 2. Please inform support of this error.", "event_espresso")));
1259 1259
 		}
1260 1260
 		global $wpdb;
1261
-		if( ! method_exists( $wpdb, $wpdb_method ) ){
1262
-			throw new EE_Error( sprintf( __( 'There is no method named "%s" on Wordpress\' $wpdb object','event_espresso' ), $wpdb_method ) );
1261
+		if ( ! method_exists($wpdb, $wpdb_method)) {
1262
+			throw new EE_Error(sprintf(__('There is no method named "%s" on Wordpress\' $wpdb object', 'event_espresso'), $wpdb_method));
1263 1263
 		}
1264
-		if( WP_DEBUG ){
1264
+		if (WP_DEBUG) {
1265 1265
 			$wpdb->last_error = NULL;
1266 1266
 			$old_show_errors_value = $wpdb->show_errors;
1267
-			$wpdb->show_errors( FALSE );
1267
+			$wpdb->show_errors(FALSE);
1268 1268
 		}
1269 1269
 
1270
-		$result = call_user_func_array( array( $wpdb, $wpdb_method ) , $arguments_to_provide );
1271
-		$this->show_db_query_if_previously_requested( $wpdb->last_query );
1272
-		if( WP_DEBUG ){
1273
-			$wpdb->show_errors( $old_show_errors_value );
1274
-			if( ! empty( $wpdb->last_error ) ){
1275
-				throw new EE_Error( sprintf( __( 'WPDB Error: "%s"', 'event_espresso' ), $wpdb->last_error ) );
1270
+		$result = call_user_func_array(array($wpdb, $wpdb_method), $arguments_to_provide);
1271
+		$this->show_db_query_if_previously_requested($wpdb->last_query);
1272
+		if (WP_DEBUG) {
1273
+			$wpdb->show_errors($old_show_errors_value);
1274
+			if ( ! empty($wpdb->last_error)) {
1275
+				throw new EE_Error(sprintf(__('WPDB Error: "%s"', 'event_espresso'), $wpdb->last_error));
1276 1276
 			}
1277 1277
 		}
1278 1278
 		return $result;
@@ -1285,7 +1285,7 @@  discard block
 block discarded – undo
1285 1285
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
1286 1286
 	 * @return string
1287 1287
 	 */
1288
-	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info){
1288
+	private function _construct_2nd_half_of_select_query(EE_Model_Query_Info_Carrier $model_query_info) {
1289 1289
 		return " FROM ".$model_query_info->get_full_join_sql().
1290 1290
 				$model_query_info->get_where_sql().
1291 1291
 				$model_query_info->get_group_by_sql().
@@ -1298,7 +1298,7 @@  discard block
 block discarded – undo
1298 1298
 	 * Set to easily debug the next X queries ran from this model.
1299 1299
 	 * @param int $count
1300 1300
 	 */
1301
-	function show_next_x_db_queries($count = 1){
1301
+	function show_next_x_db_queries($count = 1) {
1302 1302
 		$this->_show_next_x_db_queries = $count;
1303 1303
 	}
1304 1304
 
@@ -1307,8 +1307,8 @@  discard block
 block discarded – undo
1307 1307
 	/**
1308 1308
 	 * @param $sql_query
1309 1309
 	 */
1310
-	function show_db_query_if_previously_requested($sql_query){
1311
-		if($this->_show_next_x_db_queries > 0){
1310
+	function show_db_query_if_previously_requested($sql_query) {
1311
+		if ($this->_show_next_x_db_queries > 0) {
1312 1312
 			echo $sql_query;
1313 1313
 			$this->_show_next_x_db_queries--;
1314 1314
 		}
@@ -1332,7 +1332,7 @@  discard block
 block discarded – undo
1332 1332
 	 * @param array   $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
1333 1333
 	 * @return EE_Base_Class which was added as a relation. Object referred to by $other_model_id_or_obj
1334 1334
 	 */
1335
-	public function add_relationship_to($id_or_obj,$other_model_id_or_obj, $relationName, $where_query = array()){
1335
+	public function add_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
1336 1336
 		$relation_obj = $this->related_settings_for($relationName);
1337 1337
 		return $relation_obj->add_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
1338 1338
 	}
@@ -1353,9 +1353,9 @@  discard block
 block discarded – undo
1353 1353
 	 * @return boolean of success
1354 1354
 	 * @param array   $where_query This allows you to enter further query params for the relation to for relation to methods that allow you to further specify extra columns to join by (such as HABTM).  Keep in mind that the only acceptable query_params is strict "col" => "value" pairs because these will be inserted in any new rows created as well.
1355 1355
 	 */
1356
-	public function remove_relationship_to($id_or_obj,  $other_model_id_or_obj, $relationName, $where_query= array() ){
1356
+	public function remove_relationship_to($id_or_obj, $other_model_id_or_obj, $relationName, $where_query = array()) {
1357 1357
 		$relation_obj = $this->related_settings_for($relationName);
1358
-		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query );
1358
+		return $relation_obj->remove_relation_to($id_or_obj, $other_model_id_or_obj, $where_query);
1359 1359
 	}
1360 1360
 
1361 1361
 
@@ -1368,9 +1368,9 @@  discard block
 block discarded – undo
1368 1368
 	 * @param EE_Base_Class[] objects to which relations were removed
1369 1369
 	 * @return \EE_Base_Class[]
1370 1370
 	 */
1371
-	public function remove_relations($id_or_obj,$relationName,$where_query_params = array()){
1371
+	public function remove_relations($id_or_obj, $relationName, $where_query_params = array()) {
1372 1372
 		$relation_obj = $this->related_settings_for($relationName);
1373
-		return $relation_obj->remove_relations($id_or_obj, $where_query_params );
1373
+		return $relation_obj->remove_relations($id_or_obj, $where_query_params);
1374 1374
 	}
1375 1375
 
1376 1376
 
@@ -1383,10 +1383,10 @@  discard block
 block discarded – undo
1383 1383
 	 * @param array $query_params like EEM_Base::get_all
1384 1384
 	 * @return EE_Base_Class[]
1385 1385
 	 */
1386
-	function get_all_related($id_or_obj, $model_name, $query_params = null){
1386
+	function get_all_related($id_or_obj, $model_name, $query_params = null) {
1387 1387
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1388 1388
 		$relation_settings = $this->related_settings_for($model_name);
1389
-		return $relation_settings->get_all_related($model_obj,$query_params);
1389
+		return $relation_settings->get_all_related($model_obj, $query_params);
1390 1390
 	}
1391 1391
 
1392 1392
 	/**
@@ -1399,10 +1399,10 @@  discard block
 block discarded – undo
1399 1399
 	 * @param array $query_params
1400 1400
 	 * @return int how many deleted
1401 1401
 	 */
1402
-	public function delete_related($id_or_obj,$model_name, $query_params = array()){
1402
+	public function delete_related($id_or_obj, $model_name, $query_params = array()) {
1403 1403
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1404 1404
 		$relation_settings = $this->related_settings_for($model_name);
1405
-		return $relation_settings->delete_all_related($model_obj,$query_params);
1405
+		return $relation_settings->delete_all_related($model_obj, $query_params);
1406 1406
 	}
1407 1407
 
1408 1408
 	/**
@@ -1415,10 +1415,10 @@  discard block
 block discarded – undo
1415 1415
 	 * @param array $query_params
1416 1416
 	 * @return int how many deleted
1417 1417
 	 */
1418
-	public function delete_related_permanently($id_or_obj,$model_name, $query_params = array()){
1418
+	public function delete_related_permanently($id_or_obj, $model_name, $query_params = array()) {
1419 1419
 		$model_obj = $this->ensure_is_obj($id_or_obj);
1420 1420
 		$relation_settings = $this->related_settings_for($model_name);
1421
-		return $relation_settings->delete_related_permanently($model_obj,$query_params);
1421
+		return $relation_settings->delete_related_permanently($model_obj, $query_params);
1422 1422
 	}
1423 1423
 
1424 1424
 	/**
@@ -1431,17 +1431,17 @@  discard block
 block discarded – undo
1431 1431
 	 * @param bool 	 $distinct if we want to only count the distinct values for the column then you can trigger that by the setting $distinct to TRUE;
1432 1432
 	 * @return int
1433 1433
 	 */
1434
-	function count_related($id_or_obj,$model_name,$query_params = array(),$field_to_count = null, $distinct = FALSE){
1434
+	function count_related($id_or_obj, $model_name, $query_params = array(), $field_to_count = null, $distinct = FALSE) {
1435 1435
 		$related_model = $this->get_related_model_obj($model_name);
1436 1436
 		//we're just going to use the query params on the related model's normal get_all query,
1437 1437
 		//except add a condition to say to match the current mod
1438
-		if( ! isset($query_params['default_where_conditions'])){
1439
-			$query_params['default_where_conditions']='none';
1438
+		if ( ! isset($query_params['default_where_conditions'])) {
1439
+			$query_params['default_where_conditions'] = 'none';
1440 1440
 		}
1441 1441
 		$this_model_name = $this->get_this_model_name();
1442 1442
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
1443
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
1444
-		return $related_model->count($query_params,$field_to_count,$distinct);
1443
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
1444
+		return $related_model->count($query_params, $field_to_count, $distinct);
1445 1445
 	}
1446 1446
 
1447 1447
 
@@ -1455,21 +1455,21 @@  discard block
 block discarded – undo
1455 1455
 	 * @param string $field_to_sum name of field to count by. By default, uses primary key
1456 1456
 	 * @return int
1457 1457
 	 */
1458
-	function sum_related($id_or_obj,$model_name,$query_params,$field_to_sum = null){
1458
+	function sum_related($id_or_obj, $model_name, $query_params, $field_to_sum = null) {
1459 1459
 		$related_model = $this->get_related_model_obj($model_name);
1460
-		if( ! is_array( $query_params ) ){
1461
-			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1460
+		if ( ! is_array($query_params)) {
1461
+			EE_Error::doing_it_wrong('EEM_Base::sum_related', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1462 1462
 			$query_params = array();
1463 1463
 		}
1464 1464
 		//we're just going to use the query params on the related model's normal get_all query,
1465 1465
 		//except add a condition to say to match the current mod
1466
-		if( ! isset($query_params['default_where_conditions'])){
1467
-			$query_params['default_where_conditions']='none';
1466
+		if ( ! isset($query_params['default_where_conditions'])) {
1467
+			$query_params['default_where_conditions'] = 'none';
1468 1468
 		}
1469 1469
 		$this_model_name = $this->get_this_model_name();
1470 1470
 		$this_pk_field_name = $this->get_primary_key_field()->get_name();
1471
-		$query_params[0][$this_model_name.".".$this_pk_field_name]=$id_or_obj;
1472
-		return $related_model->sum($query_params,$field_to_sum);
1471
+		$query_params[0][$this_model_name.".".$this_pk_field_name] = $id_or_obj;
1472
+		return $related_model->sum($query_params, $field_to_sum);
1473 1473
 	}
1474 1474
 
1475 1475
 
@@ -1481,12 +1481,12 @@  discard block
 block discarded – undo
1481 1481
 	 * @param array $query_params like EEM_Base::get_all's
1482 1482
 	 * @return EE_Base_Class
1483 1483
 	 */
1484
-	public function get_first_related( EE_Base_Class $id_or_obj, $other_model_name, $query_params ){
1485
-		$query_params['limit']=1;
1486
-		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
1487
-		if( $results ){
1484
+	public function get_first_related(EE_Base_Class $id_or_obj, $other_model_name, $query_params) {
1485
+		$query_params['limit'] = 1;
1486
+		$results = $this->get_all_related($id_or_obj, $other_model_name, $query_params);
1487
+		if ($results) {
1488 1488
 			return array_shift($results);
1489
-		}else{
1489
+		} else {
1490 1490
 			return null;
1491 1491
 		}
1492 1492
 
@@ -1496,8 +1496,8 @@  discard block
 block discarded – undo
1496 1496
 	 * Gets the model's name as it's expected in queries. For example, if this is EEM_Event model, that would be Event
1497 1497
 	 * @return string
1498 1498
 	 */
1499
-	function get_this_model_name(){
1500
-		return str_replace("EEM_","",get_class($this));
1499
+	function get_this_model_name() {
1500
+		return str_replace("EEM_", "", get_class($this));
1501 1501
 	}
1502 1502
 
1503 1503
 	/**
@@ -1505,14 +1505,14 @@  discard block
 block discarded – undo
1505 1505
 	 * @return EE_Any_Foreign_Model_Name_Field
1506 1506
 	 * @throws EE_Error
1507 1507
 	 */
1508
-	public function get_field_containing_related_model_name(){
1509
-		foreach($this->field_settings(true) as $field){
1510
-			if($field instanceof EE_Any_Foreign_Model_Name_Field){
1508
+	public function get_field_containing_related_model_name() {
1509
+		foreach ($this->field_settings(true) as $field) {
1510
+			if ($field instanceof EE_Any_Foreign_Model_Name_Field) {
1511 1511
 				$field_with_model_name = $field;
1512 1512
 			}
1513 1513
 		}
1514
-		if( !isset($field_with_model_name) || !$field_with_model_name ){
1515
-			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name() ));
1514
+		if ( ! isset($field_with_model_name) || ! $field_with_model_name) {
1515
+			throw new EE_Error(sprintf(__("There is no EE_Any_Foreign_Model_Name field on model %s", "event_espresso"), $this->get_this_model_name()));
1516 1516
 		}
1517 1517
 		return $field_with_model_name;
1518 1518
 	}
@@ -1533,18 +1533,18 @@  discard block
 block discarded – undo
1533 1533
 	 * @return int new primary key on main table that got inserted
1534 1534
 	 * @throws EE_Error
1535 1535
 	 */
1536
-	function insert($field_n_values){
1536
+	function insert($field_n_values) {
1537 1537
 		/**
1538 1538
 		 * Filters the fields and their values before inserting an item using the models
1539 1539
 		 * @param array $fields_n_values keys are the fields and values are their new values
1540 1540
 		 * @param EEM_Base $model the model used
1541 1541
 		 */
1542
-		$field_n_values = apply_filters( 'FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this );
1543
-		if($this->_satisfies_unique_indexes($field_n_values)){
1542
+		$field_n_values = apply_filters('FHEE__EEM_Base__insert__fields_n_values', $field_n_values, $this);
1543
+		if ($this->_satisfies_unique_indexes($field_n_values)) {
1544 1544
 			$main_table = $this->_get_main_table();
1545 1545
 			$new_id = $this->_insert_into_specific_table($main_table, $field_n_values, false);
1546
-			foreach($this->_get_other_tables() as $other_table){
1547
-				$this->_insert_into_specific_table($other_table, $field_n_values,$new_id);
1546
+			foreach ($this->_get_other_tables() as $other_table) {
1547
+				$this->_insert_into_specific_table($other_table, $field_n_values, $new_id);
1548 1548
 			}
1549 1549
 			/**
1550 1550
 			 * Done just after attempting to insert a new model object
@@ -1553,9 +1553,9 @@  discard block
 block discarded – undo
1553 1553
 			 * @param array $fields_n_values fields and their values
1554 1554
 			 * @param int|string the ID of the newly-inserted model object
1555 1555
 			 */
1556
-			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
1556
+			do_action('AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id);
1557 1557
 			return $new_id;
1558
-		}else{
1558
+		} else {
1559 1559
 			return FALSE;
1560 1560
 		}
1561 1561
 	}
@@ -1568,11 +1568,11 @@  discard block
 block discarded – undo
1568 1568
 	 * @param string $action
1569 1569
 	 * @return boolean
1570 1570
 	 */
1571
-	protected function _satisfies_unique_indexes($field_n_values,$action = 'insert'){
1572
-		foreach($this->unique_indexes() as $index_name => $index){
1571
+	protected function _satisfies_unique_indexes($field_n_values, $action = 'insert') {
1572
+		foreach ($this->unique_indexes() as $index_name => $index) {
1573 1573
 			$uniqueness_where_params = array_intersect_key($field_n_values, $index->fields());
1574
-			if($this->exists(array($uniqueness_where_params))){
1575
-				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"),$action,$this->_get_class_name(),$index_name,implode(",",$index->field_names()),http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__ );
1574
+			if ($this->exists(array($uniqueness_where_params))) {
1575
+				EE_Error::add_error(sprintf(__("Could not %s %s. %s uniqueness index failed. Fields %s must form a unique set, but an entry already exists with values %s.", "event_espresso"), $action, $this->_get_class_name(), $index_name, implode(",", $index->field_names()), http_build_query($uniqueness_where_params)), __FILE__, __FUNCTION__, __LINE__);
1576 1576
 				return false;
1577 1577
 			}
1578 1578
 		}
@@ -1593,28 +1593,28 @@  discard block
 block discarded – undo
1593 1593
 	 * @throws EE_Error
1594 1594
 	 * @return EE_Base_Class
1595 1595
 	 */
1596
-	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
1597
-		if($obj_or_fields_array instanceof EE_Base_Class){
1596
+	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true) {
1597
+		if ($obj_or_fields_array instanceof EE_Base_Class) {
1598 1598
 			$fields_n_values = $obj_or_fields_array->model_field_array();
1599
-		}elseif( is_array($obj_or_fields_array)){
1599
+		}elseif (is_array($obj_or_fields_array)) {
1600 1600
 			$fields_n_values = $obj_or_fields_array;
1601
-		}else{
1602
-			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
1601
+		} else {
1602
+			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"), get_class($this), $obj_or_fields_array));
1603 1603
 		}
1604 1604
 		$query_params = array();
1605
-		if( $this->has_primary_key_field() &&
1606
-				( $include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
1607
-				isset($fields_n_values[$this->primary_key_name()])){
1605
+		if ($this->has_primary_key_field() &&
1606
+				($include_primary_key || $this->get_primary_key_field() instanceof EE_Primary_Key_String_Field) &&
1607
+				isset($fields_n_values[$this->primary_key_name()])) {
1608 1608
 			$query_params[0]['OR'][$this->primary_key_name()] = $fields_n_values[$this->primary_key_name()];
1609 1609
 		}
1610
-		foreach($this->unique_indexes() as $unique_index_name=>$unique_index){
1610
+		foreach ($this->unique_indexes() as $unique_index_name=>$unique_index) {
1611 1611
 			$uniqueness_where_params = array_intersect_key($fields_n_values, $unique_index->fields());
1612 1612
 			$query_params[0]['OR']['AND*'.$unique_index_name] = $uniqueness_where_params;
1613 1613
 		}
1614 1614
 		//if there is nothing to base this search on, then we shouldn't find anything
1615
-		if( empty( $query_params ) ){
1615
+		if (empty($query_params)) {
1616 1616
 			return array();
1617
-		}else{
1617
+		} else {
1618 1618
 			return $this->get_one($query_params);
1619 1619
 		}
1620 1620
 	}
@@ -1624,7 +1624,7 @@  discard block
 block discarded – undo
1624 1624
 	 * @param array $query_params
1625 1625
 	 * @return boolean
1626 1626
 	 */
1627
-	function exists($query_params){
1627
+	function exists($query_params) {
1628 1628
 		$query_params['limit'] = 1;
1629 1629
 		return $this->count($query_params) > 0;
1630 1630
 	}
@@ -1634,7 +1634,7 @@  discard block
 block discarded – undo
1634 1634
 	 * @param int|string $id
1635 1635
 	 * @return boolean
1636 1636
 	 */
1637
-	function exists_by_ID($id){
1637
+	function exists_by_ID($id) {
1638 1638
 		return $this->exists(array('default_where_conditions'=>'none', array($this->primary_key_name() => $id)));
1639 1639
 	}
1640 1640
 
@@ -1654,42 +1654,42 @@  discard block
 block discarded – undo
1654 1654
 	 * @global WPDB $wpdb only used to get the $wpdb->insert_id after performing an insert
1655 1655
 	 * @return int ID of new row inserted
1656 1656
 	 */
1657
-	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0 ){
1657
+	protected function _insert_into_specific_table(EE_Table_Base $table, $fields_n_values, $new_id = 0) {
1658 1658
 		global $wpdb;
1659 1659
 		$insertion_col_n_values = array();
1660 1660
 		$format_for_insertion = array();
1661 1661
 		$fields_on_table = $this->_get_fields_for_table($table->get_table_alias());
1662
-		foreach($fields_on_table as $field_name => $field_obj){
1662
+		foreach ($fields_on_table as $field_name => $field_obj) {
1663 1663
 			//check if its an auto-incrementing column, in which case we should just leave it to do its autoincrement thing
1664
-			if($field_obj->is_auto_increment()){
1664
+			if ($field_obj->is_auto_increment()) {
1665 1665
 				continue;
1666 1666
 			}
1667 1667
 			$prepared_value = $this->_prepare_value_or_use_default($field_obj, $fields_n_values);
1668 1668
 			//if the value we want to assign it to is NULL, just don't mention it for the insertion
1669
-			if( $prepared_value !== NULL ){
1670
-				$insertion_col_n_values[ $field_obj->get_table_column() ] = $prepared_value;
1669
+			if ($prepared_value !== NULL) {
1670
+				$insertion_col_n_values[$field_obj->get_table_column()] = $prepared_value;
1671 1671
 				$format_for_insertion[] = $field_obj->get_wpdb_data_type();
1672 1672
 			}
1673 1673
 		}
1674 1674
 
1675
-		if($table instanceof EE_Secondary_Table && $new_id){
1675
+		if ($table instanceof EE_Secondary_Table && $new_id) {
1676 1676
 			//its not the main table, so we should have already saved the main table's PK which we just inserted
1677 1677
 			//so add the fk to the main table as a column
1678 1678
 			$insertion_col_n_values[$table->get_fk_on_table()] = $new_id;
1679
-			$format_for_insertion[]='%d';//yes right now we're only allowing these foreign keys to be INTs
1679
+			$format_for_insertion[] = '%d'; //yes right now we're only allowing these foreign keys to be INTs
1680 1680
 		}
1681 1681
 		//insert the new entry
1682
-		$this->_do_wpdb_query( 'insert', array( $table->get_table_name(), $insertion_col_n_values, $format_for_insertion ) );
1682
+		$this->_do_wpdb_query('insert', array($table->get_table_name(), $insertion_col_n_values, $format_for_insertion));
1683 1683
 		//ok, now what do we return for the ID of the newly-inserted thing?
1684
-		if($this->has_primary_key_field()){
1685
-			if($this->get_primary_key_field()->is_auto_increment()){
1684
+		if ($this->has_primary_key_field()) {
1685
+			if ($this->get_primary_key_field()->is_auto_increment()) {
1686 1686
 				return $wpdb->insert_id;
1687
-			}else{
1687
+			} else {
1688 1688
 				//it's not an auto-increment primary key, so
1689 1689
 				//it must have been supplied
1690 1690
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
1691 1691
 			}
1692
-		}else{
1692
+		} else {
1693 1693
 			//we can't return a  primary key because there is none. instead return
1694 1694
 			//a unique string indicating this model
1695 1695
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -1704,15 +1704,15 @@  discard block
 block discarded – undo
1704 1704
 	 * @param array $fields_n_values
1705 1705
 	 * @return mixed string|int|float depending on what the table column will be expecting
1706 1706
 	 */
1707
-	protected function _prepare_value_or_use_default( $field_obj, $fields_n_values ){
1707
+	protected function _prepare_value_or_use_default($field_obj, $fields_n_values) {
1708 1708
 		//if this field doesn't allow nullable, don't allow it
1709
-		if( ! $field_obj->is_nullable() && (
1710
-				! isset( $fields_n_values[ $field_obj->get_name() ] ) ||
1711
-				$fields_n_values[ $field_obj->get_name() ] === NULL ) ){
1712
-			$fields_n_values[ $field_obj->get_name() ] = $field_obj->get_default_value();
1709
+		if ( ! $field_obj->is_nullable() && (
1710
+				! isset($fields_n_values[$field_obj->get_name()]) ||
1711
+				$fields_n_values[$field_obj->get_name()] === NULL )) {
1712
+			$fields_n_values[$field_obj->get_name()] = $field_obj->get_default_value();
1713 1713
 		}
1714
-		$unprepared_value = isset( $fields_n_values[ $field_obj->get_name() ] ) ? $fields_n_values[ $field_obj->get_name() ] : NULL;
1715
-		return $this->_prepare_value_for_use_in_db( $unprepared_value, $field_obj);
1714
+		$unprepared_value = isset($fields_n_values[$field_obj->get_name()]) ? $fields_n_values[$field_obj->get_name()] : NULL;
1715
+		return $this->_prepare_value_for_use_in_db($unprepared_value, $field_obj);
1716 1716
 	}
1717 1717
 
1718 1718
 
@@ -1724,9 +1724,9 @@  discard block
 block discarded – undo
1724 1724
 	 * @param EE_Model_Field_Base $field field which will be doing the preparing of the value. If null, we assume $value is a custom selection
1725 1725
 	 * @return mixed a value ready for use in the database for insertions, updating, or in a where clause
1726 1726
 	 */
1727
-	private function _prepare_value_for_use_in_db($value, $field){
1728
-		if($field && $field instanceof EE_Model_Field_Base){
1729
-			switch( $this->_values_already_prepared_by_model_object ){
1727
+	private function _prepare_value_for_use_in_db($value, $field) {
1728
+		if ($field && $field instanceof EE_Model_Field_Base) {
1729
+			switch ($this->_values_already_prepared_by_model_object) {
1730 1730
 				case self::not_prepared_by_model_object:
1731 1731
 					$value = $field->prepare_for_set($value);
1732 1732
 					//purposefully left out "return"
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
 					//leave the value alone
1737 1737
 			}
1738 1738
 			return $value;
1739
-		}else{
1739
+		} else {
1740 1740
 			return $value;
1741 1741
 		}
1742 1742
 	}
@@ -1746,13 +1746,13 @@  discard block
 block discarded – undo
1746 1746
 	 * @return EE_Primary_Table
1747 1747
 	 * @throws EE_Error
1748 1748
 	 */
1749
-	protected function _get_main_table(){
1750
-		foreach($this->_tables as $table){
1751
-			if($table instanceof EE_Primary_Table){
1749
+	protected function _get_main_table() {
1750
+		foreach ($this->_tables as $table) {
1751
+			if ($table instanceof EE_Primary_Table) {
1752 1752
 				return $table;
1753 1753
 			}
1754 1754
 		}
1755
-		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor','event_espresso'),get_class($this)));
1755
+		throw new EE_Error(sprintf(__('There are no main tables on %s. They should be added to _tables array in the constructor', 'event_espresso'), get_class($this)));
1756 1756
 	}
1757 1757
 
1758 1758
 	/**
@@ -1771,7 +1771,7 @@  discard block
 block discarded – undo
1771 1771
 	 */
1772 1772
 	public function second_table() {
1773 1773
 		// grab second table from tables array
1774
-		$second_table = end( $this->_tables );
1774
+		$second_table = end($this->_tables);
1775 1775
 		return $second_table instanceof EE_Secondary_Table ? $second_table->get_table_name() : NULL;
1776 1776
 	}
1777 1777
 
@@ -1784,8 +1784,8 @@  discard block
 block discarded – undo
1784 1784
 	 * @param string $table_alias
1785 1785
 	 * @return EE_Primary_Table | EE_Secondary_Table
1786 1786
 	 */
1787
-	public function get_table_obj_by_alias( $table_alias = '' ) {
1788
-		return isset( $this->_tables[ $table_alias ] ) ? $this->_tables[ $table_alias ] : NULL;
1787
+	public function get_table_obj_by_alias($table_alias = '') {
1788
+		return isset($this->_tables[$table_alias]) ? $this->_tables[$table_alias] : NULL;
1789 1789
 	}
1790 1790
 
1791 1791
 
@@ -1794,10 +1794,10 @@  discard block
 block discarded – undo
1794 1794
 	 * Gets all the tables of type EE_Other_Table from EEM_CPT_Basel_Model::_tables
1795 1795
 	 * @return EE_Secondary_Table[]
1796 1796
 	 */
1797
-	protected function _get_other_tables(){
1798
-		$other_tables =array();
1799
-		foreach($this->_tables as $table_alias => $table){
1800
-			if($table instanceof EE_Secondary_Table){
1797
+	protected function _get_other_tables() {
1798
+		$other_tables = array();
1799
+		foreach ($this->_tables as $table_alias => $table) {
1800
+			if ($table instanceof EE_Secondary_Table) {
1801 1801
 				$other_tables[$table_alias] = $table;
1802 1802
 			}
1803 1803
 		}
@@ -1809,7 +1809,7 @@  discard block
 block discarded – undo
1809 1809
 	 * @param string $table_alias, array key in EEM_Base::_tables
1810 1810
 	 * @return EE_Model_Field_Base[]
1811 1811
 	 */
1812
-	function _get_fields_for_table($table_alias){
1812
+	function _get_fields_for_table($table_alias) {
1813 1813
 		return $this->_fields[$table_alias];
1814 1814
 	}
1815 1815
 
@@ -1821,29 +1821,29 @@  discard block
 block discarded – undo
1821 1821
 	 * @param array $query_params like EEM_Base::get_all's $query_parameters['where']
1822 1822
 	 * @return EE_Model_Query_Info_Carrier
1823 1823
 	 */
1824
-	function _extract_related_models_from_query($query_params){
1824
+	function _extract_related_models_from_query($query_params) {
1825 1825
 		$query_info_carrier = new EE_Model_Query_Info_Carrier();
1826
-		if(array_key_exists(0,$query_params)){
1827
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,0);
1826
+		if (array_key_exists(0, $query_params)) {
1827
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 0);
1828 1828
 		}
1829
-		if(array_key_exists('group_by', $query_params)){
1830
-			if(is_array($query_params['group_by'])){
1831
-				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
1832
-			}elseif( ! empty ( $query_params['group_by'] )){
1833
-				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
1829
+		if (array_key_exists('group_by', $query_params)) {
1830
+			if (is_array($query_params['group_by'])) {
1831
+				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'], $query_info_carrier, 'group_by');
1832
+			}elseif ( ! empty ($query_params['group_by'])) {
1833
+				$this->_extract_related_model_info_from_query_param($query_params['group_by'], $query_info_carrier, 'group_by');
1834 1834
 			}
1835 1835
 		}
1836
-		if(array_key_exists('having',$query_params)){
1837
-			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
1836
+		if (array_key_exists('having', $query_params)) {
1837
+			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier, 'having');
1838 1838
 		}
1839
-		if(array_key_exists('order_by', $query_params)){
1840
-			if ( is_array( $query_params['order_by'] ) )
1841
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
1842
-			elseif( ! empty( $query_params['order_by'] ))
1843
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
1839
+		if (array_key_exists('order_by', $query_params)) {
1840
+			if (is_array($query_params['order_by']))
1841
+				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_info_carrier, 'order_by');
1842
+			elseif ( ! empty($query_params['order_by']))
1843
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_info_carrier, 'order_by');
1844 1844
 		}
1845
-		if(array_key_exists('force_join', $query_params)){
1846
-			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
1845
+		if (array_key_exists('force_join', $query_params)) {
1846
+			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'], $query_info_carrier, 'force_join');
1847 1847
 		}
1848 1848
 		return $query_info_carrier;
1849 1849
 	}
@@ -1856,34 +1856,34 @@  discard block
 block discarded – undo
1856 1856
 	 * @throws EE_Error
1857 1857
 	 * @return \EE_Model_Query_Info_Carrier
1858 1858
 	 */
1859
-	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
1860
-		if (!empty($sub_query_params)){
1859
+	private function _extract_related_models_from_sub_params_array_keys($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
1860
+		if ( ! empty($sub_query_params)) {
1861 1861
 			$sub_query_params = (array) $sub_query_params;
1862
-			foreach($sub_query_params as $param => $possibly_array_of_params){
1862
+			foreach ($sub_query_params as $param => $possibly_array_of_params) {
1863 1863
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
1864
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier,$query_param_type);
1864
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
1865 1865
 
1866 1866
 				//if $possibly_array_of_params is an array, try recursing into it, searching for keys which
1867 1867
 				//indicate needed joins. Eg, array('NOT'=>array('Registration.TXN_ID'=>23)). In this case, we tried
1868 1868
 				//extracting models out of the 'NOT', which obviously wasn't successful, and then we recurse into the value
1869 1869
 				//of array('Registration.TXN_ID'=>23)
1870 1870
 				$query_param_sans_stars = $this->_remove_stars_and_anything_after_from_condition_query_param_key($param);
1871
-				if(in_array($query_param_sans_stars, $this->_logic_query_param_keys,true)){
1872
-					if (! is_array($possibly_array_of_params)){
1871
+				if (in_array($query_param_sans_stars, $this->_logic_query_param_keys, true)) {
1872
+					if ( ! is_array($possibly_array_of_params)) {
1873 1873
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
1874
-							$param,$possibly_array_of_params));
1875
-					}else{
1876
-						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
1874
+							$param, $possibly_array_of_params));
1875
+					} else {
1876
+						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier, $query_param_type);
1877 1877
 					}
1878
-				}elseif($query_param_type === 0 //ie WHERE
1878
+				}elseif ($query_param_type === 0 //ie WHERE
1879 1879
 						&& is_array($possibly_array_of_params)
1880 1880
 						&& isset($possibly_array_of_params[2])
1881
-						&& $possibly_array_of_params[2] == true){
1881
+						&& $possibly_array_of_params[2] == true) {
1882 1882
 					//then $possible_array_of_params looks something like array('<','DTT_sold',true)
1883 1883
 					//indicating that $possible_array_of_params[1] is actually a field name,
1884 1884
 					//from which we should extract query parameters!
1885
-					if(! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])){
1886
-						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"),$query_param_type,implode(",",$possibly_array_of_params)));
1885
+					if ( ! isset($possibly_array_of_params[0]) || ! isset($possibly_array_of_params[1])) {
1886
+						throw new EE_Error(sprintf(__("Improperly formed query parameter %s. It should be numerically indexed like array('<','DTT_sold',true); but you provided %s", "event_espresso"), $query_param_type, implode(",", $possibly_array_of_params)));
1887 1887
 					}
1888 1888
 					$this->_extract_related_model_info_from_query_param($possibly_array_of_params[1], $model_query_info_carrier, $query_param_type);
1889 1889
 				}
@@ -1902,14 +1902,14 @@  discard block
 block discarded – undo
1902 1902
 	 * @throws EE_Error
1903 1903
 	 * @return \EE_Model_Query_Info_Carrier
1904 1904
 	 */
1905
-	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier,$query_param_type){
1906
-		if (!empty($sub_query_params)){
1907
-			if(!is_array($sub_query_params)){
1908
-				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"),$sub_query_params));
1905
+	private function _extract_related_models_from_sub_params_array_values($sub_query_params, EE_Model_Query_Info_Carrier $model_query_info_carrier, $query_param_type) {
1906
+		if ( ! empty($sub_query_params)) {
1907
+			if ( ! is_array($sub_query_params)) {
1908
+				throw new EE_Error(sprintf(__("Query parameter %s should be an array, but it isn't.", "event_espresso"), $sub_query_params));
1909 1909
 			}
1910
-			foreach($sub_query_params as $param){
1910
+			foreach ($sub_query_params as $param) {
1911 1911
 				//$param could be simply 'EVT_ID', or it could be 'Registrations.REG_ID', or even 'Registrations.Transactions.Payments.PAY_amount'
1912
-				$this->_extract_related_model_info_from_query_param( $param, $model_query_info_carrier, $query_param_type);
1912
+				$this->_extract_related_model_info_from_query_param($param, $model_query_info_carrier, $query_param_type);
1913 1913
 			}
1914 1914
 		}
1915 1915
 		return $model_query_info_carrier;
@@ -1928,75 +1928,75 @@  discard block
 block discarded – undo
1928 1928
 	 * @throws EE_Error
1929 1929
 	 * @return EE_Model_Query_Info_Carrier
1930 1930
 	 */
1931
-	function _create_model_query_info_carrier($query_params){
1932
-		if( ! is_array( $query_params ) ){
1933
-			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
1931
+	function _create_model_query_info_carrier($query_params) {
1932
+		if ( ! is_array($query_params)) {
1933
+			EE_Error::doing_it_wrong('EEM_Base::_create_model_query_info_carrier', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
1934 1934
 			$query_params = array();
1935 1935
 		}
1936 1936
 		$query_object = $this->_extract_related_models_from_query($query_params);
1937
-		if(array_key_exists(0,$query_params)){
1937
+		if (array_key_exists(0, $query_params)) {
1938 1938
 			$where_query_params = $query_params[0];
1939
-		}else{
1939
+		} else {
1940 1940
 			$where_query_params = array();
1941 1941
 		}
1942 1942
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
1943
-		foreach($where_query_params as $key => $value){
1944
-			if(is_int($key)){
1945
-				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. Please read documentation on EEM_Base::get_all.", "event_espresso"),$key, $value,get_class($this)));
1943
+		foreach ($where_query_params as $key => $value) {
1944
+			if (is_int($key)) {
1945
+				throw new EE_Error(sprintf(__("WHERE query params must NOT be numerically-indexed. You provided the array key '%s' for value '%s' while querying model %s. Please read documentation on EEM_Base::get_all.", "event_espresso"), $key, $value, get_class($this)));
1946 1946
 			}
1947 1947
 		}
1948
-		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
1948
+		if (array_key_exists('default_where_conditions', $query_params) && ! empty($query_params['default_where_conditions'])) {
1949 1949
 			$use_default_where_conditions = $query_params['default_where_conditions'];
1950
-		}else{
1950
+		} else {
1951 1951
 			$use_default_where_conditions = 'all';
1952 1952
 		}
1953
-		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
1954
-		$query_object->set_where_sql( $this->_construct_where_clause($where_query_params));
1953
+		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object, $use_default_where_conditions, $where_query_params), $where_query_params);
1954
+		$query_object->set_where_sql($this->_construct_where_clause($where_query_params));
1955 1955
 
1956 1956
 
1957 1957
 		//if this is a "on_join_limit" then we are limiting on on a specific table in a multi_table join.  So we need to setup a subquery and use that for the main join.  Note for now this only works on the primary table for the model.  So for instance, you could set the limit array like this:
1958 1958
 		//array( 'on_join_limit' => array('Primary_Table_Alias', array(1,10) ) )
1959
-		if ( array_key_exists('on_join_limit', $query_params ) && ! empty( $query_params['on_join_limit'] )) {
1960
-			$query_object->set_main_model_join_sql( $this->_construct_limit_join_select( $query_params['on_join_limit'][0], $query_params['on_join_limit'][1] ) );
1959
+		if (array_key_exists('on_join_limit', $query_params) && ! empty($query_params['on_join_limit'])) {
1960
+			$query_object->set_main_model_join_sql($this->_construct_limit_join_select($query_params['on_join_limit'][0], $query_params['on_join_limit'][1]));
1961 1961
 		}
1962 1962
 
1963 1963
 
1964 1964
 		//set limit
1965
-		if(array_key_exists('limit',$query_params)){
1966
-			if(is_array($query_params['limit'])){
1967
-				if( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])){
1968
-					$e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"),  http_build_query($query_params['limit']));
1965
+		if (array_key_exists('limit', $query_params)) {
1966
+			if (is_array($query_params['limit'])) {
1967
+				if ( ! isset($query_params['limit'][0]) || ! isset($query_params['limit'][1])) {
1968
+					$e = sprintf(__("Invalid DB query. You passed '%s' for the LIMIT, but only the following are valid: an integer, string representing an integer, a string like 'int,int', or an array like array(int,int)", "event_espresso"), http_build_query($query_params['limit']));
1969 1969
 					throw new EE_Error($e."|".$e);
1970 1970
 				}
1971 1971
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
1972 1972
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
1973
-			}elseif( ! empty ( $query_params['limit'] )){
1973
+			}elseif ( ! empty ($query_params['limit'])) {
1974 1974
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
1975 1975
 			}
1976 1976
 		}
1977 1977
 		//set order by
1978
-		if(array_key_exists('order_by',$query_params)){
1979
-			if(is_array($query_params['order_by'])){
1978
+		if (array_key_exists('order_by', $query_params)) {
1979
+			if (is_array($query_params['order_by'])) {
1980 1980
 				//if they're using 'order_by' as an array, they can't use 'order' (because 'order_by' must
1981 1981
 				//specify whether to ascend or descend on each field. Eg 'order_by'=>array('EVT_ID'=>'ASC'). So
1982 1982
 				//including 'order' wouldn't make any sense if 'order_by' has already specified which way to order!
1983
-				if(array_key_exists('order', $query_params)){
1983
+				if (array_key_exists('order', $query_params)) {
1984 1984
 					throw new EE_Error(sprintf(__("In querying %s, we are using query parameter 'order_by' as an array (keys:%s,values:%s), and so we can't use query parameter 'order' (value %s). You should just use the 'order_by' parameter ", "event_espresso"),
1985
-							get_class($this),implode(", ",array_keys($query_params['order_by'])),implode(", ",$query_params['order_by']),$query_params['order']));
1985
+							get_class($this), implode(", ", array_keys($query_params['order_by'])), implode(", ", $query_params['order_by']), $query_params['order']));
1986 1986
 				}
1987
-				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_object,'order_by');
1987
+				 $this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'], $query_object, 'order_by');
1988 1988
 				//assume it's an array of fields to order by
1989 1989
 				$order_array = array();
1990
-				foreach($query_params['order_by'] as $field_name_to_order_by => $order){
1990
+				foreach ($query_params['order_by'] as $field_name_to_order_by => $order) {
1991 1991
 					$order = $this->_extract_order($order);
1992 1992
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
1993 1993
 				}
1994
-				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
1995
-			}elseif( ! empty ( $query_params['order_by'] )){
1996
-				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
1997
-				if(isset($query_params['order'])){
1994
+				$query_object->set_order_by_sql(" ORDER BY ".implode(",", $order_array));
1995
+			}elseif ( ! empty ($query_params['order_by'])) {
1996
+				$this->_extract_related_model_info_from_query_param($query_params['order_by'], $query_object, 'order', $query_params['order_by']);
1997
+				if (isset($query_params['order'])) {
1998 1998
 					$order = $this->_extract_order($query_params['order']);
1999
-				}else{
1999
+				} else {
2000 2000
 					$order = 'DESC';
2001 2001
 				}
2002 2002
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2004,46 +2004,46 @@  discard block
 block discarded – undo
2004 2004
 		}
2005 2005
 
2006 2006
 		//if 'order_by' wasn't set, maybe they are just using 'order' on its own?
2007
-		if( ! array_key_exists('order_by',$query_params) && array_key_exists('order',$query_params) && ! empty( $query_params['order'] )){
2007
+		if ( ! array_key_exists('order_by', $query_params) && array_key_exists('order', $query_params) && ! empty($query_params['order'])) {
2008 2008
 			$pk_field = $this->get_primary_key_field();
2009 2009
 			$order = $this->_extract_order($query_params['order']);
2010 2010
 			$query_object->set_order_by_sql(" ORDER BY ".$pk_field->get_qualified_column().SP.$order);
2011 2011
 		}
2012 2012
 
2013 2013
 		//set group by
2014
-		if(array_key_exists('group_by',$query_params)){
2015
-			if(is_array($query_params['group_by'])){
2014
+		if (array_key_exists('group_by', $query_params)) {
2015
+			if (is_array($query_params['group_by'])) {
2016 2016
 				//it's an array, so assume we'll be grouping by a bunch of stuff
2017 2017
 				$group_by_array = array();
2018
-				foreach($query_params['group_by'] as $field_name_to_group_by){
2018
+				foreach ($query_params['group_by'] as $field_name_to_group_by) {
2019 2019
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2020 2020
 				}
2021
-				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2022
-			}elseif( ! empty ( $query_params['group_by'] )){
2021
+				$query_object->set_group_by_sql(" GROUP BY ".implode(", ", $group_by_array));
2022
+			}elseif ( ! empty ($query_params['group_by'])) {
2023 2023
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2024 2024
 			}
2025 2025
 		}
2026 2026
 		//set having
2027
-		if(array_key_exists('having',$query_params) && $query_params['having']){
2028
-			$query_object->set_having_sql( $this->_construct_having_clause($query_params['having']));
2027
+		if (array_key_exists('having', $query_params) && $query_params['having']) {
2028
+			$query_object->set_having_sql($this->_construct_having_clause($query_params['having']));
2029 2029
 		}
2030 2030
 
2031 2031
 		//now, just verify they didn't pass anything wack
2032
-		foreach($query_params as $query_key => $query_value){
2033
-			if( ! in_array($query_key,$this->_allowed_query_params,true)){
2032
+		foreach ($query_params as $query_key => $query_value) {
2033
+			if ( ! in_array($query_key, $this->_allowed_query_params, true)) {
2034 2034
 				throw new EE_Error(
2035 2035
 					sprintf(
2036
-						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s",'event_espresso'),
2036
+						__("You passed %s as a query parameter to %s, which is illegal! The allowed query parameters are %s", 'event_espresso'),
2037 2037
 						$query_key,
2038 2038
 						get_class($this),
2039 2039
 //						print_r( $this->_allowed_query_params, TRUE )
2040
-						implode( ',', $this->_allowed_query_params )
2040
+						implode(',', $this->_allowed_query_params)
2041 2041
 					)
2042 2042
 				);
2043 2043
 			}
2044 2044
 		}
2045 2045
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2046
-		if ( empty( $main_model_join_sql ) )
2046
+		if (empty($main_model_join_sql))
2047 2047
 			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2048 2048
 		return $query_object;
2049 2049
 	}
@@ -2057,11 +2057,11 @@  discard block
 block discarded – undo
2057 2057
 	 * @return string either ASC, asc, DESC or desc
2058 2058
 	 * @throws EE_Error
2059 2059
 	 */
2060
-	private function _extract_order($should_be_order_string){
2061
-		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2060
+	private function _extract_order($should_be_order_string) {
2061
+		if (in_array($should_be_order_string, $this->_allowed_order_values)) {
2062 2062
 			return $should_be_order_string;
2063
-		}else{
2064
-			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2063
+		} else {
2064
+			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"), get_class($this), $should_be_order_string));
2065 2065
 		}
2066 2066
 	}
2067 2067
 
@@ -2079,19 +2079,19 @@  discard block
 block discarded – undo
2079 2079
 	 * @throws EE_Error
2080 2080
 	 * @return array like $query_params[0], see EEM_Base::get_all for documentation
2081 2081
 	 */
2082
-	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier,$use_default_where_conditions = 'all',$where_query_params = array()){
2083
-		$allowed_used_default_where_conditions_values = array('all','this_model_only', 'other_models_only','none');
2084
-		if( ! in_array($use_default_where_conditions,$allowed_used_default_where_conditions_values)){
2085
-			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"),$use_default_where_conditions,implode(", ",$allowed_used_default_where_conditions_values)));
2082
+	private function _get_default_where_conditions_for_models_in_query(EE_Model_Query_Info_Carrier $query_info_carrier, $use_default_where_conditions = 'all', $where_query_params = array()) {
2083
+		$allowed_used_default_where_conditions_values = array('all', 'this_model_only', 'other_models_only', 'none');
2084
+		if ( ! in_array($use_default_where_conditions, $allowed_used_default_where_conditions_values)) {
2085
+			throw new EE_Error(sprintf(__("You passed an invalid value to the query parameter 'default_where_conditions' of '%s'. Allowed values are %s", "event_espresso"), $use_default_where_conditions, implode(", ", $allowed_used_default_where_conditions_values)));
2086 2086
 		}
2087
-		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2087
+		if (in_array($use_default_where_conditions, array('all', 'this_model_only'))) {
2088 2088
 			$universal_query_params = $this->_get_default_where_conditions();
2089
-		}else{
2089
+		} else {
2090 2090
 			$universal_query_params = array();
2091 2091
 		}
2092 2092
 
2093
-		if(in_array($use_default_where_conditions,array('all','other_models_only'))){
2094
-			foreach($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name){
2093
+		if (in_array($use_default_where_conditions, array('all', 'other_models_only'))) {
2094
+			foreach ($query_info_carrier->get_model_names_included() as $model_relation_path => $model_name) {
2095 2095
 				$related_model = $this->get_related_model_obj($model_name);
2096 2096
 				$related_model_universal_where_params = $related_model->_get_default_where_conditions($model_relation_path);
2097 2097
 
@@ -2118,22 +2118,22 @@  discard block
 block discarded – undo
2118 2118
 	 * @param string $model_relation_path like 'Transaction.Payment.'
2119 2119
 	 * @return array like EEM_Base::get_all's $query_params[0]
2120 2120
 	 */
2121
-	private function _override_defaults_or_make_null_friendly($default_where_conditions,$provided_where_conditions,$model,$model_relation_path){
2121
+	private function _override_defaults_or_make_null_friendly($default_where_conditions, $provided_where_conditions, $model, $model_relation_path) {
2122 2122
 		$null_friendly_where_conditions = array();
2123 2123
 		$none_overridden = true;
2124 2124
 		$or_condition_key_for_defaults = 'OR*'.get_class($model);
2125 2125
 
2126
-		foreach($default_where_conditions as $key => $val){
2127
-			if( isset($provided_where_conditions[$key])){
2126
+		foreach ($default_where_conditions as $key => $val) {
2127
+			if (isset($provided_where_conditions[$key])) {
2128 2128
 				$none_overridden = false;
2129
-			}else{
2129
+			} else {
2130 2130
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2131 2131
 			}
2132 2132
 		}
2133
-		if( $none_overridden && $default_where_conditions){
2134
-			if($model->has_primary_key_field()){
2133
+		if ($none_overridden && $default_where_conditions) {
2134
+			if ($model->has_primary_key_field()) {
2135 2135
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2136
-			}else{
2136
+			} else {
2137 2137
 				//@todo NO PK, use other defaults
2138 2138
 			}
2139 2139
 		}
@@ -2148,8 +2148,8 @@  discard block
 block discarded – undo
2148 2148
 	 * @param string $model_relation_path eg, path from Event to Payment is "Registration.Transaction.Payment."
2149 2149
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2150 2150
 	 */
2151
-	private function _get_default_where_conditions($model_relation_path = null){
2152
-		if ( $this->_ignore_where_strategy )
2151
+	private function _get_default_where_conditions($model_relation_path = null) {
2152
+		if ($this->_ignore_where_strategy)
2153 2153
 			return array();
2154 2154
 
2155 2155
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
@@ -2160,13 +2160,13 @@  discard block
 block discarded – undo
2160 2160
 	 * @param EE_Model_Query_Info_Carrier $model_query_info
2161 2161
 	 * @return string
2162 2162
 	 */
2163
-	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info){
2163
+	private function _construct_default_select_sql(EE_Model_Query_Info_Carrier $model_query_info) {
2164 2164
 		$selects = $this->_get_columns_to_select_for_this_model();
2165
-		foreach($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included){
2165
+		foreach ($model_query_info->get_model_names_included() as $model_relation_chain => $name_of_other_model_included) {
2166 2166
 			$other_model_included = $this->get_related_model_obj($name_of_other_model_included);
2167 2167
 			$selects = array_merge($selects, $other_model_included->_get_columns_to_select_for_this_model($model_relation_chain));
2168 2168
 		}
2169
-		return implode(", ",$selects);
2169
+		return implode(", ", $selects);
2170 2170
 	}
2171 2171
 
2172 2172
 	/**
@@ -2175,19 +2175,19 @@  discard block
 block discarded – undo
2175 2175
 	 * @param string $model_relation_chain like 'Question.Question_Group.Event'
2176 2176
 	 * @return array numerically indexed, values are columns to select and rename, eg "Event.ID AS 'Event.ID'"
2177 2177
 	 */
2178
-	public function _get_columns_to_select_for_this_model($model_relation_chain = ''){
2178
+	public function _get_columns_to_select_for_this_model($model_relation_chain = '') {
2179 2179
 		$fields = $this->field_settings();
2180 2180
 		$selects = array();
2181 2181
 		$table_alias_with_model_relation_chain_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_prefix($model_relation_chain, $this->get_this_model_name());
2182
-		foreach($fields as $field_obj){
2183
-			$selects[] = $table_alias_with_model_relation_chain_prefix . $field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
2182
+		foreach ($fields as $field_obj) {
2183
+			$selects[] = $table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()." AS '".$table_alias_with_model_relation_chain_prefix.$field_obj->get_table_alias().".".$field_obj->get_table_column()."'";
2184 2184
 		}
2185 2185
 		//make sure we are also getting the PKs of each table
2186 2186
 		$tables = $this->get_tables();
2187
-		if(count($tables) > 1){
2188
-			foreach($tables as $table_obj){
2189
-				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix . $table_obj->get_fully_qualified_pk_column();
2190
-				if( ! in_array($qualified_pk_column,$selects)){
2187
+		if (count($tables) > 1) {
2188
+			foreach ($tables as $table_obj) {
2189
+				$qualified_pk_column = $table_alias_with_model_relation_chain_prefix.$table_obj->get_fully_qualified_pk_column();
2190
+				if ( ! in_array($qualified_pk_column, $selects)) {
2191 2191
 					$selects[] = "$qualified_pk_column AS '$qualified_pk_column'";
2192 2192
 				}
2193 2193
 			}
@@ -2211,65 +2211,65 @@  discard block
 block discarded – undo
2211 2211
 	 * @throws EE_Error
2212 2212
 	 * @return void only modifies the EEM_Related_Model_Info_Carrier passed into it
2213 2213
 	 */
2214
-	private function _extract_related_model_info_from_query_param( $query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL ){
2215
-		if($original_query_param == NULL){
2214
+	private function _extract_related_model_info_from_query_param($query_param, EE_Model_Query_Info_Carrier $passed_in_query_info, $query_param_type, $original_query_param = NULL) {
2215
+		if ($original_query_param == NULL) {
2216 2216
 			$original_query_param = $query_param;
2217 2217
 		}
2218 2218
 		$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);
2219 2219
 		/** @var $allow_logic_query_params bool whether or not to allow logic_query_params like 'NOT','OR', or 'AND' */
2220
-		$allow_logic_query_params = in_array($query_param_type,array('where','having'));
2221
-		$allow_fields = in_array($query_param_type,array('where','having','order_by','group_by','order'));
2220
+		$allow_logic_query_params = in_array($query_param_type, array('where', 'having'));
2221
+		$allow_fields = in_array($query_param_type, array('where', 'having', 'order_by', 'group_by', 'order'));
2222 2222
 		//check to see if we have a field on this model
2223 2223
 		$this_model_fields = $this->field_settings(true);
2224
-		if(array_key_exists($query_param,$this_model_fields)){
2225
-			if($allow_fields){
2224
+		if (array_key_exists($query_param, $this_model_fields)) {
2225
+			if ($allow_fields) {
2226 2226
 				return;
2227
-			}else{
2227
+			} else {
2228 2228
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
2229
-						$query_param,get_class($this),$query_param_type,$original_query_param));
2229
+						$query_param, get_class($this), $query_param_type, $original_query_param));
2230 2230
 			}
2231 2231
 		}
2232 2232
 		//check if this is a special logic query param
2233
-		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2234
-			if($allow_logic_query_params){
2233
+		elseif (in_array($query_param, $this->_logic_query_param_keys, TRUE)) {
2234
+			if ($allow_logic_query_params) {
2235 2235
 				return;
2236
-			}else{
2236
+			} else {
2237 2237
 				throw new EE_Error(
2238 2238
 					sprintf(
2239
-						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
2240
-						implode( '", "', $this->_logic_query_param_keys ),
2241
-						$query_param ,
2242
-						get_class( $this ),
2239
+						__('Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso'),
2240
+						implode('", "', $this->_logic_query_param_keys),
2241
+						$query_param,
2242
+						get_class($this),
2243 2243
 						'<br />',
2244
-						"\t" . ' $passed_in_query_info = <pre>' . print_r( $passed_in_query_info, TRUE ) . '</pre>' . "\n\t" . ' $query_param_type = ' . $query_param_type . "\n\t" . ' $original_query_param = ' . $original_query_param
2244
+						"\t".' $passed_in_query_info = <pre>'.print_r($passed_in_query_info, TRUE).'</pre>'."\n\t".' $query_param_type = '.$query_param_type."\n\t".' $original_query_param = '.$original_query_param
2245 2245
 					)
2246 2246
 				);
2247 2247
 			}
2248 2248
 		}
2249 2249
 		//check if it's a custom selection
2250
-		elseif(array_key_exists($query_param,$this->_custom_selections)){
2250
+		elseif (array_key_exists($query_param, $this->_custom_selections)) {
2251 2251
 			return;
2252 2252
 		}
2253 2253
 
2254 2254
 		//check if has a model name at the beginning
2255 2255
 		//and
2256 2256
 		//check if it's a field on a related model
2257
-		foreach($this->_model_relations as $valid_related_model_name=>$relation_obj){
2258
-			if(strpos($query_param, $valid_related_model_name.".") === 0){
2259
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2257
+		foreach ($this->_model_relations as $valid_related_model_name=>$relation_obj) {
2258
+			if (strpos($query_param, $valid_related_model_name.".") === 0) {
2259
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2260 2260
 				$query_param = substr($query_param, strlen($valid_related_model_name."."));
2261
-				if($query_param == ''){
2261
+				if ($query_param == '') {
2262 2262
 					//nothing left to $query_param
2263 2263
 					//we should actually end in a field name, not a model like this!
2264 2264
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2265
-					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2266
-				}else{
2265
+					$query_param, $query_param_type, get_class($this), $valid_related_model_name));
2266
+				} else {
2267 2267
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2268 2268
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2269 2269
 					return;
2270 2270
 				}
2271
-			}elseif($query_param == $valid_related_model_name){
2272
-				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2271
+			}elseif ($query_param == $valid_related_model_name) {
2272
+				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info, $original_query_param);
2273 2273
 				return;
2274 2274
 			}
2275 2275
 		}
@@ -2279,7 +2279,7 @@  discard block
 block discarded – undo
2279 2279
 		//and we previously confirmed it wasn't a logic query param or field on the current model
2280 2280
 		//it's wack, that's what it is
2281 2281
 		throw new EE_Error(sprintf(__("There is no model named '%s' related to %s. Query param type is %s and original query param is %s", "event_espresso"),
2282
-				$query_param,get_class($this),$query_param_type,$original_query_param));
2282
+				$query_param, get_class($this), $query_param_type, $original_query_param));
2283 2283
 
2284 2284
 	}
2285 2285
 
@@ -2296,26 +2296,26 @@  discard block
 block discarded – undo
2296 2296
 	 * what models to prepend onto its default query params or in case it wants to rename tables (in case there are multiple joins to the same table)
2297 2297
 	 * @return void
2298 2298
 	 */
2299
-	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info,$original_query_param){
2299
+	private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) {
2300 2300
 		$relation_obj = $this->related_settings_for($model_name);
2301 2301
 
2302 2302
 		$model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param);
2303 2303
 		//check if the relation is HABTM, because then we're essentially doing two joins
2304 2304
 		//If so, join first to the JOIN table, and add its data types, and then continue as normal
2305
-		if($relation_obj instanceof EE_HABTM_Relation){
2305
+		if ($relation_obj instanceof EE_HABTM_Relation) {
2306 2306
 			$join_model_obj = $relation_obj->get_join_model();
2307 2307
 			//replace the model specified with the join model for this relation chain, whi
2308 2308
 			$relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain);
2309 2309
 			$new_query_info = new EE_Model_Query_Info_Carrier(
2310 2310
 					array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()),
2311 2311
 					$relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model));
2312
-			$passed_in_query_info->merge( $new_query_info  );
2312
+			$passed_in_query_info->merge($new_query_info);
2313 2313
 		}
2314 2314
 		//now just join to the other table pointed to by the relation object, and add its data types
2315 2315
 		$new_query_info = new EE_Model_Query_Info_Carrier(
2316 2316
 				array($model_relation_chain=>$model_name),
2317 2317
 				$relation_obj->get_join_statement($model_relation_chain));
2318
-		$passed_in_query_info->merge( $new_query_info  );
2318
+		$passed_in_query_info->merge($new_query_info);
2319 2319
 	}
2320 2320
 
2321 2321
 
@@ -2324,11 +2324,11 @@  discard block
 block discarded – undo
2324 2324
 	 * @param array $where_params like EEM_Base::get_all
2325 2325
 	 * @return string of SQL
2326 2326
 	 */
2327
-	private function _construct_where_clause($where_params){
2327
+	private function _construct_where_clause($where_params) {
2328 2328
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
2329
-		if($SQL){
2330
-			return " WHERE ". $SQL;
2331
-		}else{
2329
+		if ($SQL) {
2330
+			return " WHERE ".$SQL;
2331
+		} else {
2332 2332
 			return '';
2333 2333
 		}
2334 2334
 	}
@@ -2339,11 +2339,11 @@  discard block
 block discarded – undo
2339 2339
 	 * @param array $having_params
2340 2340
 	 * @return string
2341 2341
 	 */
2342
-	private function _construct_having_clause($having_params){
2342
+	private function _construct_having_clause($having_params) {
2343 2343
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
2344
-		if($SQL){
2345
-			return " HAVING ". $SQL;
2346
-		}else{
2344
+		if ($SQL) {
2345
+			return " HAVING ".$SQL;
2346
+		} else {
2347 2347
 			return '';
2348 2348
 		}
2349 2349
 
@@ -2357,17 +2357,17 @@  discard block
 block discarded – undo
2357 2357
 	 * @return EE_Model_Field_Base
2358 2358
 	 * @throws EE_Error
2359 2359
 	 */
2360
-	protected function _get_field_on_model($field_name,$model_name){
2360
+	protected function _get_field_on_model($field_name, $model_name) {
2361 2361
 		$model_class = 'EEM_'.$model_name;
2362 2362
 		$model_filepath = $model_class.".model.php";
2363
-		EE_Registry::instance()->load_helper( 'File' );
2364
-		if ( is_readable($model_filepath)){
2363
+		EE_Registry::instance()->load_helper('File');
2364
+		if (is_readable($model_filepath)) {
2365 2365
 			require_once($model_filepath);
2366
-			$model_instance=call_user_func($model_name."::instance");
2366
+			$model_instance = call_user_func($model_name."::instance");
2367 2367
 			/* @var $model_instance EEM_Base */
2368 2368
 			return $model_instance->field_settings_for($field_name);
2369
-		}else{
2370
-			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
2369
+		} else {
2370
+			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s', 'event_espresso'), $model_name, $model_class, $model_filepath));
2371 2371
 		}
2372 2372
 	}
2373 2373
 
@@ -2380,43 +2380,43 @@  discard block
 block discarded – undo
2380 2380
 	 * @throws EE_Error
2381 2381
 	 * @return string of SQL
2382 2382
 	 */
2383
-	private function _construct_condition_clause_recursive($where_params, $glue = ' AND'){
2384
-		$where_clauses=array();
2385
-		foreach($where_params as $query_param => $op_and_value_or_sub_condition){
2386
-			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param);//str_replace("*",'',$query_param);
2387
-			if(in_array($query_param,$this->_logic_query_param_keys)){
2388
-				switch($query_param){
2383
+	private function _construct_condition_clause_recursive($where_params, $glue = ' AND') {
2384
+		$where_clauses = array();
2385
+		foreach ($where_params as $query_param => $op_and_value_or_sub_condition) {
2386
+			$query_param = $this->_remove_stars_and_anything_after_from_condition_query_param_key($query_param); //str_replace("*",'',$query_param);
2387
+			if (in_array($query_param, $this->_logic_query_param_keys)) {
2388
+				switch ($query_param) {
2389 2389
 					case 'not':
2390 2390
 					case 'NOT':
2391
-						$where_clauses[] = "! (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
2391
+						$where_clauses[] = "! (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, $glue).")";
2392 2392
 						break;
2393 2393
 					case 'and':
2394 2394
 					case 'AND':
2395
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ') .")";
2395
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' AND ').")";
2396 2396
 						break;
2397 2397
 					case 'or':
2398 2398
 					case 'OR':
2399
-						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
2399
+						$where_clauses[] = " (".$this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ').")";
2400 2400
 						break;
2401 2401
 				}
2402
-			}else{
2402
+			} else {
2403 2403
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
2404 2404
 
2405 2405
 				//if it's not a normal field, maybe it's a custom selection?
2406
-				if( ! $field_obj){
2407
-					if(isset( $this->_custom_selections[$query_param][1])){
2406
+				if ( ! $field_obj) {
2407
+					if (isset($this->_custom_selections[$query_param][1])) {
2408 2408
 						$field_obj = $this->_custom_selections[$query_param][1];
2409
-					}else{
2410
-						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
2409
+					} else {
2410
+						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"), $query_param));
2411 2411
 					}
2412 2412
 				}
2413 2413
 				$op_and_value_sql = $this->_construct_op_and_value($op_and_value_or_sub_condition, $field_obj);
2414
-				$where_clauses[]=$this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
2414
+				$where_clauses[] = $this->_deduce_column_name_from_query_param($query_param).SP.$op_and_value_sql;
2415 2415
 			}
2416 2416
 		}
2417
-		if($where_clauses){
2418
-			$SQL = implode($glue,$where_clauses);
2419
-		}else{
2417
+		if ($where_clauses) {
2418
+			$SQL = implode($glue, $where_clauses);
2419
+		} else {
2420 2420
 			$SQL = '';
2421 2421
 		}
2422 2422
 		return $SQL;
@@ -2430,18 +2430,18 @@  discard block
 block discarded – undo
2430 2430
 	 * @throws EE_Error
2431 2431
 	 * @return string table alias and column name for SQL, eg "Transaction.TXN_ID"
2432 2432
 	 */
2433
-	private function _deduce_column_name_from_query_param($query_param){
2433
+	private function _deduce_column_name_from_query_param($query_param) {
2434 2434
 		$field = $this->_deduce_field_from_query_param($query_param);
2435 2435
 
2436
-		if( $field ){
2437
-			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
2438
-			return $table_alias_prefix . $field->get_qualified_column();
2439
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
2436
+		if ($field) {
2437
+			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param($field->get_model_name(), $query_param);
2438
+			return $table_alias_prefix.$field->get_qualified_column();
2439
+		}elseif (array_key_exists($query_param, $this->_custom_selections)) {
2440 2440
 			//maybe it's custom selection item?
2441 2441
 			//if so, just use it as the "column name"
2442 2442
 			return $query_param;
2443
-		}else{
2444
-			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
2443
+		} else {
2444
+			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"), $query_param, implode(",", $this->_custom_selections)));
2445 2445
 		}
2446 2446
 	}
2447 2447
 
@@ -2453,11 +2453,11 @@  discard block
 block discarded – undo
2453 2453
 	 * @param string $condition_query_param_key
2454 2454
 	 * @return string
2455 2455
 	 */
2456
-	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key){
2456
+	private function _remove_stars_and_anything_after_from_condition_query_param_key($condition_query_param_key) {
2457 2457
 		$pos_of_star = strpos($condition_query_param_key, '*');
2458
-		if($pos_of_star === FALSE){
2458
+		if ($pos_of_star === FALSE) {
2459 2459
 			return $condition_query_param_key;
2460
-		}else{
2460
+		} else {
2461 2461
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
2462 2462
 			return $condition_query_param_sans_star;
2463 2463
 		}
@@ -2472,54 +2472,54 @@  discard block
 block discarded – undo
2472 2472
 	 * @throws EE_Error
2473 2473
 	 * @return string
2474 2474
 	 */
2475
-	private function _construct_op_and_value($op_and_value, $field_obj){
2476
-		if(is_array( $op_and_value )){
2475
+	private function _construct_op_and_value($op_and_value, $field_obj) {
2476
+		if (is_array($op_and_value)) {
2477 2477
 			$operator = isset($op_and_value[0]) ? $this->_prepare_operator_for_sql($op_and_value[0]) : null;
2478
-			if( ! $operator){
2478
+			if ( ! $operator) {
2479 2479
 				$php_array_like_string = array();
2480
-				foreach($op_and_value as $key => $value){
2480
+				foreach ($op_and_value as $key => $value) {
2481 2481
 					$php_array_like_string[] = "$key=>$value";
2482 2482
 				}
2483
-				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string)));
2483
+				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",", $php_array_like_string)));
2484 2484
 			}
2485 2485
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
2486
-		}else{
2486
+		} else {
2487 2487
 			$operator = '=';
2488 2488
 			$value = $op_and_value;
2489 2489
 		}
2490 2490
 
2491 2491
 		//check to see if the value is actually another field
2492
-		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
2492
+		if (is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true) {
2493 2493
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
2494
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
2494
+		}elseif (in_array($operator, $this->_in_style_operators) && is_array($value)) {
2495 2495
 			//in this case, the value should be an array, or at least a comma-separated list
2496 2496
 			//it will need to handle a little differently
2497 2497
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
2498 2498
 			//note: $cleaned_value has already been run through $wpdb->prepare()
2499 2499
 			return $operator.SP.$cleaned_value;
2500
-		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
2500
+		} elseif (in_array($operator, $this->_between_style_operators) && is_array($value)) {
2501 2501
 			//the value should be an array with count of two.
2502
-			if ( count($value) !== 2 )
2503
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
2504
-			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
2502
+			if (count($value) !== 2)
2503
+				throw new EE_Error(sprintf(__("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN"));
2504
+			$cleaned_value = $this->_construct_between_value($value, $field_obj);
2505 2505
 			return $operator.SP.$cleaned_value;
2506
-		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
2507
-			if($value != NULL){
2508
-				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
2506
+		} elseif (in_array($operator, $this->_null_style_operators)) {
2507
+			if ($value != NULL) {
2508
+				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"), $value, $operator));
2509 2509
 			}
2510 2510
 			return $operator;
2511
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
2511
+		}elseif ($operator == 'LIKE' && ! is_array($value)) {
2512 2512
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
2513 2513
 			//remove other junk. So just treat it as a string.
2514 2514
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
2515
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2516
-			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
2517
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2518
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
2519
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
2520
-			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
2521
-		}else{
2522
-			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
2515
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
2516
+			return $operator.SP.$this->_wpdb_prepare_using_field($value, $field_obj);
2517
+		}elseif (in_array($operator, $this->_in_style_operators) && ! is_array($value)) {
2518
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))", 'event_espresso'), $operator, $operator));
2519
+		}elseif ( ! in_array($operator, $this->_in_style_operators) && is_array($value)) {
2520
+			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))", 'event_espresso'), $operator, $operator));
2521
+		} else {
2522
+			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"), http_build_query($op_and_value)));
2523 2523
 		}
2524 2524
 	}
2525 2525
 
@@ -2531,12 +2531,12 @@  discard block
 block discarded – undo
2531 2531
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be the datatype to be used when querying, eg '%s'
2532 2532
 	 * @return string
2533 2533
 	 */
2534
-	function _construct_between_value( $values, $field_obj ) {
2534
+	function _construct_between_value($values, $field_obj) {
2535 2535
 		$cleaned_values = array();
2536
-		foreach ( $values as $value ) {
2537
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
2536
+		foreach ($values as $value) {
2537
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
2538 2538
 		}
2539
-		return  $cleaned_values[0] . " AND " . $cleaned_values[1];
2539
+		return  $cleaned_values[0]." AND ".$cleaned_values[1];
2540 2540
 	}
2541 2541
 
2542 2542
 
@@ -2552,26 +2552,26 @@  discard block
 block discarded – undo
2552 2552
 	 * @param EE_Model_Field_Base|string $field_obj if string, it should be a wpdb data type like '%s', or '%d'
2553 2553
 	 * @return string of SQL to follow an 'IN' or 'NOT IN' operator
2554 2554
 	 */
2555
-	function _construct_in_value($values,  $field_obj){
2555
+	function _construct_in_value($values, $field_obj) {
2556 2556
 		//check if the value is a CSV list
2557
-		if(is_string($values)){
2557
+		if (is_string($values)) {
2558 2558
 			//in which case, turn it into an array
2559
-			$values = explode(",",$values);
2559
+			$values = explode(",", $values);
2560 2560
 		}
2561 2561
 		$cleaned_values = array();
2562
-		foreach($values as $value){
2563
-			$cleaned_values[] = $this->_wpdb_prepare_using_field($value,$field_obj);
2562
+		foreach ($values as $value) {
2563
+			$cleaned_values[] = $this->_wpdb_prepare_using_field($value, $field_obj);
2564 2564
 		}
2565 2565
 		//we would just LOVE to leave $cleaned_values as an empty array, and return the value as "()",
2566 2566
 		//but unfortunately that's invalid SQL. So instead we return a string which we KNOW will evaluate to be the empty set
2567 2567
 		//which is effectively equivalent to returning "()". We don't return "(0)" because that only works for auto-incrementing columns
2568
-		if(empty($cleaned_values)){
2568
+		if (empty($cleaned_values)) {
2569 2569
 			$all_fields = $this->field_settings();
2570 2570
 			$a_field = array_shift($all_fields);
2571 2571
 			$main_table = $this->_get_main_table();
2572 2572
 			$cleaned_values[] = "SELECT ".$a_field->get_table_column()." FROM ".$main_table->get_table_name()." WHERE FALSE";
2573 2573
 		}
2574
-		return "(".implode(",",$cleaned_values).")";
2574
+		return "(".implode(",", $cleaned_values).")";
2575 2575
 	}
2576 2576
 
2577 2577
 
@@ -2583,15 +2583,15 @@  discard block
 block discarded – undo
2583 2583
 	 * @throws EE_Error
2584 2584
 	 * @return false|null|string
2585 2585
 	 */
2586
-	private function _wpdb_prepare_using_field($value,$field_obj){
2586
+	private function _wpdb_prepare_using_field($value, $field_obj) {
2587 2587
 		global $wpdb;
2588
-		if($field_obj instanceof EE_Model_Field_Base){
2589
-			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
2590
-		}else{//$field_obj should really just be a data type
2591
-			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
2592
-				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
2588
+		if ($field_obj instanceof EE_Model_Field_Base) {
2589
+			return $wpdb->prepare($field_obj->get_wpdb_data_type(), $this->_prepare_value_for_use_in_db($value, $field_obj));
2590
+		} else {//$field_obj should really just be a data type
2591
+			if ( ! in_array($field_obj, $this->_valid_wpdb_data_types)) {
2592
+				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"), $field_obj, implode(",", $this->_valid_wpdb_data_types)));
2593 2593
 			}
2594
-			return $wpdb->prepare($field_obj,$value);
2594
+			return $wpdb->prepare($field_obj, $value);
2595 2595
 		}
2596 2596
 	}
2597 2597
 
@@ -2603,27 +2603,27 @@  discard block
 block discarded – undo
2603 2603
 	 * @throws EE_Error
2604 2604
 	 * @return EE_Model_Field_Base
2605 2605
 	 */
2606
-	protected function _deduce_field_from_query_param($query_param_name){
2606
+	protected function _deduce_field_from_query_param($query_param_name) {
2607 2607
 		//ok, now proceed with deducing which part is the model's name, and which is the field's name
2608 2608
 		//which will help us find the database table and column
2609 2609
 
2610
-		$query_param_parts = explode(".",$query_param_name);
2611
-		if(empty($query_param_parts)){
2612
-			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s",'event_espresso'),$query_param_name));
2610
+		$query_param_parts = explode(".", $query_param_name);
2611
+		if (empty($query_param_parts)) {
2612
+			throw new EE_Error(sprintf(__("_extract_column_name is empty when trying to extract column and table name from %s", 'event_espresso'), $query_param_name));
2613 2613
 		}
2614 2614
 		$number_of_parts = count($query_param_parts);
2615
-		$last_query_param_part = $query_param_parts[ count($query_param_parts) - 1 ];
2616
-		if($number_of_parts == 1){
2615
+		$last_query_param_part = $query_param_parts[count($query_param_parts) - 1];
2616
+		if ($number_of_parts == 1) {
2617 2617
 			$field_name = $last_query_param_part;
2618 2618
 			$model_obj = $this;
2619
-		}else{// $number_of_parts >= 2
2619
+		} else {// $number_of_parts >= 2
2620 2620
 			//the last part is the column name, and there are only 2parts. therefore...
2621 2621
 			$field_name = $last_query_param_part;
2622
-			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
2622
+			$model_obj = $this->get_related_model_obj($query_param_parts[$number_of_parts - 2]);
2623 2623
 		}
2624
-		try{
2624
+		try {
2625 2625
 			return $model_obj->field_settings_for($field_name);
2626
-		}catch(EE_Error $e){
2626
+		} catch (EE_Error $e) {
2627 2627
 			return null;
2628 2628
 		}
2629 2629
 	}
@@ -2637,13 +2637,13 @@  discard block
 block discarded – undo
2637 2637
 	 * @throws EE_Error
2638 2638
 	 * @return string
2639 2639
 	 */
2640
-	function _get_qualified_column_for_field($field_name){
2640
+	function _get_qualified_column_for_field($field_name) {
2641 2641
 		$all_fields = $this->field_settings();
2642 2642
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
2643
-		if($field){
2643
+		if ($field) {
2644 2644
 			return $field->get_qualified_column();
2645
-		}else{
2646
-			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
2645
+		} else {
2646
+			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.", 'event_espresso'), $field_name, get_class($this)));
2647 2647
 		}
2648 2648
 	}
2649 2649
 
@@ -2657,14 +2657,14 @@  discard block
 block discarded – undo
2657 2657
 	 * @param  mixed|string $limit The limit for this select
2658 2658
 	 * @return string 				The final select join element for the query.
2659 2659
 	 */
2660
-	function _construct_limit_join_select( $table_alias, $limit ) {
2660
+	function _construct_limit_join_select($table_alias, $limit) {
2661 2661
 		$SQL = '';
2662 2662
 
2663
-		foreach ( $this->_tables as $table_obj ) {
2664
-			if ( $table_obj instanceof EE_Primary_Table ) {
2665
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit( $limit ) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
2666
-			} elseif ( $table_obj instanceof EE_Secondary_Table ) {
2667
-				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP . $table_obj->get_join_sql( $table_alias ).SP;
2663
+		foreach ($this->_tables as $table_obj) {
2664
+			if ($table_obj instanceof EE_Primary_Table) {
2665
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit($limit) : SP.$table_obj->get_table_name()." AS ".$table_obj->get_table_alias().SP;
2666
+			} elseif ($table_obj instanceof EE_Secondary_Table) {
2667
+				$SQL .= $table_alias == $table_obj->get_table_alias() ? $table_obj->get_select_join_limit_join($limit) : SP.$table_obj->get_join_sql($table_alias).SP;
2668 2668
 			}
2669 2669
 		}
2670 2670
 		return $SQL;
@@ -2677,7 +2677,7 @@  discard block
 block discarded – undo
2677 2677
 	 * Eg "wp_post AS Event" or "wp_post AS Event INNER JOIN wp_postmeta Event_Meta ON Event.ID = Event_Meta.post_id"
2678 2678
 	 * @return string SQL
2679 2679
 	 */
2680
-	function _construct_internal_join(){
2680
+	function _construct_internal_join() {
2681 2681
 		$SQL = $this->_get_main_table()->get_table_sql();
2682 2682
 		$SQL .= $this->_construct_internal_join_to_table_with_alias($this->_get_main_table()->get_table_alias());
2683 2683
 		return $SQL;
@@ -2698,17 +2698,17 @@  discard block
 block discarded – undo
2698 2698
 	 * @param string $alias_prefixed table alias to join to (this table should already be in the FROM SQL clause)
2699 2699
 	 * @return string
2700 2700
 	 */
2701
-	function _construct_internal_join_to_table_with_alias($alias_prefixed){
2701
+	function _construct_internal_join_to_table_with_alias($alias_prefixed) {
2702 2702
 		$SQL = '';
2703 2703
 		$alias_sans_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($alias_prefixed);
2704
-		foreach($this->_tables as $table_obj){
2705
-			if($table_obj instanceof EE_Secondary_Table){//table is secondary table
2706
-				if($alias_sans_prefix == $table_obj->get_table_alias()){
2704
+		foreach ($this->_tables as $table_obj) {
2705
+			if ($table_obj instanceof EE_Secondary_Table) {//table is secondary table
2706
+				if ($alias_sans_prefix == $table_obj->get_table_alias()) {
2707 2707
 					//so we're joining to this table, meaning the table is already in
2708 2708
 					//the FROM statement, BUT the primary table isn't. So we want
2709 2709
 					//to add the inverse join sql
2710 2710
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
2711
-				}else{
2711
+				} else {
2712 2712
 					//just add a regular JOIN to this table from the primary table
2713 2713
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
2714 2714
 				}
@@ -2722,9 +2722,9 @@  discard block
 block discarded – undo
2722 2722
 	 * This should be a growing array of keys being table-columns (eg 'EVT_ID' and 'Event.EVT_ID'), and values being their data type (eg, '%s', '%d', etc)
2723 2723
 	 * @return array
2724 2724
 	 */
2725
-	function _get_data_types(){
2725
+	function _get_data_types() {
2726 2726
 		$data_types = array();
2727
-		foreach(array_values($this->field_settings()) as $field_obj){
2727
+		foreach (array_values($this->field_settings()) as $field_obj) {
2728 2728
 			//$data_types[$field_obj->get_table_column()] = $field_obj->get_wpdb_data_type();
2729 2729
 			/** @var $field_obj EE_Model_Field_Base */
2730 2730
 			$data_types[$field_obj->get_qualified_column()] = $field_obj->get_wpdb_data_type();
@@ -2740,11 +2740,11 @@  discard block
 block discarded – undo
2740 2740
 	 * @throws EE_Error
2741 2741
 	 * @return EEM_Base
2742 2742
 	 */
2743
-	function get_related_model_obj($model_name){
2743
+	function get_related_model_obj($model_name) {
2744 2744
 
2745 2745
 		$model_classname = "EEM_".$model_name;
2746
-		if(!class_exists($model_classname)){
2747
-			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s",'event_espresso'),$model_name,$model_classname));
2746
+		if ( ! class_exists($model_classname)) {
2747
+			throw new EE_Error(sprintf(__("You specified a related model named %s in your query. No such model exists, if it did, it would have the classname %s", 'event_espresso'), $model_name, $model_classname));
2748 2748
 		}
2749 2749
 		$model_obj = call_user_func($model_classname."::instance");
2750 2750
 		return $model_obj;
@@ -2755,7 +2755,7 @@  discard block
 block discarded – undo
2755 2755
 	 * Returns the array of EE_ModelRelations for this model.
2756 2756
 	 * @return EE_Model_Relation_Base[]
2757 2757
 	 */
2758
-	public function relation_settings(){
2758
+	public function relation_settings() {
2759 2759
 		return $this->_model_relations;
2760 2760
 	}
2761 2761
 
@@ -2765,10 +2765,10 @@  discard block
 block discarded – undo
2765 2765
 	 * (Eg, without an event, datetimes have little purpose.)
2766 2766
 	 * @return EE_Belongs_To_Relation[]
2767 2767
 	 */
2768
-	public function belongs_to_relations(){
2768
+	public function belongs_to_relations() {
2769 2769
 		$belongs_to_relations = array();
2770
-		foreach($this->relation_settings() as $model_name => $relation_obj){
2771
-			if($relation_obj instanceof EE_Belongs_To_Relation){
2770
+		foreach ($this->relation_settings() as $model_name => $relation_obj) {
2771
+			if ($relation_obj instanceof EE_Belongs_To_Relation) {
2772 2772
 				$belongs_to_relations[$model_name] = $relation_obj;
2773 2773
 			}
2774 2774
 		}
@@ -2783,15 +2783,15 @@  discard block
 block discarded – undo
2783 2783
 	 * @throws EE_Error
2784 2784
 	 * @return EE_Model_Relation_Base
2785 2785
 	 */
2786
-	public function related_settings_for($relation_name){
2787
-		$relatedModels=$this->relation_settings();
2788
-		if(!array_key_exists($relation_name,$relatedModels)){
2786
+	public function related_settings_for($relation_name) {
2787
+		$relatedModels = $this->relation_settings();
2788
+		if ( ! array_key_exists($relation_name, $relatedModels)) {
2789 2789
 			throw new EE_Error(
2790 2790
 				sprintf(
2791
-					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...','event_espresso'),
2791
+					__('Cannot get %s related to %s. There is no model relation of that type. There is, however, %s...', 'event_espresso'),
2792 2792
 					$relation_name,
2793 2793
 					$this->_get_class_name(),
2794
-					implode( ', ', array_keys( $relatedModels ))
2794
+					implode(', ', array_keys($relatedModels))
2795 2795
 				)
2796 2796
 			);
2797 2797
 		}
@@ -2806,10 +2806,10 @@  discard block
 block discarded – undo
2806 2806
 	 * @throws EE_Error
2807 2807
 	 * @return EE_Model_Field_Base
2808 2808
 	 */
2809
-	public function field_settings_for($fieldName){
2810
-		$fieldSettings=$this->field_settings(true);
2811
-		if( ! array_key_exists($fieldName,$fieldSettings)){
2812
-			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'",'event_espresso'),$fieldName,get_class($this)));
2809
+	public function field_settings_for($fieldName) {
2810
+		$fieldSettings = $this->field_settings(true);
2811
+		if ( ! array_key_exists($fieldName, $fieldSettings)) {
2812
+			throw new EE_Error(sprintf(__("There is no field/column '%s' on '%s'", 'event_espresso'), $fieldName, get_class($this)));
2813 2813
 		}
2814 2814
 		return $fieldSettings[$fieldName];
2815 2815
 	}
@@ -2819,11 +2819,11 @@  discard block
 block discarded – undo
2819 2819
 	 * @param string $fieldName a key in the model's _field_settings array
2820 2820
 	 * @return boolean
2821 2821
 	 */
2822
-	public function has_field($fieldName){
2822
+	public function has_field($fieldName) {
2823 2823
 		$fieldSettings = $this->field_settings(true);
2824
-		if( isset($fieldSettings[$fieldName])){
2824
+		if (isset($fieldSettings[$fieldName])) {
2825 2825
 			return true;
2826
-		}else{
2826
+		} else {
2827 2827
 			return false;
2828 2828
 		}
2829 2829
 	}
@@ -2833,11 +2833,11 @@  discard block
 block discarded – undo
2833 2833
 	 * @param string $relation_name possibly one of the keys in the relation_settings array
2834 2834
 	 * @return boolean
2835 2835
 	 */
2836
-	public function has_relation($relation_name){
2836
+	public function has_relation($relation_name) {
2837 2837
 		$relations = $this->relation_settings();
2838
-		if(isset($relations[$relation_name])){
2838
+		if (isset($relations[$relation_name])) {
2839 2839
 			return true;
2840
-		}else{
2840
+		} else {
2841 2841
 			return false;
2842 2842
 		}
2843 2843
 	}
@@ -2849,7 +2849,7 @@  discard block
 block discarded – undo
2849 2849
 	 * @param $field_obj
2850 2850
 	 * @return EE_Model_Field_Base
2851 2851
 	 */
2852
-	public function is_primary_key_field( $field_obj ){
2852
+	public function is_primary_key_field($field_obj) {
2853 2853
 		return $field_obj instanceof EE_Primary_Key_Field_Base ? TRUE : FALSE;
2854 2854
 	}
2855 2855
 
@@ -2861,16 +2861,16 @@  discard block
 block discarded – undo
2861 2861
 	 * @return EE_Model_Field_Base
2862 2862
 	 * @throws EE_Error
2863 2863
 	 */
2864
-	public function get_primary_key_field(){
2865
-		if( $this->_primary_key_field === NULL ){
2866
-			foreach( $this->field_settings( TRUE ) as $field_obj ){
2867
-				if( $this->is_primary_key_field( $field_obj )){
2864
+	public function get_primary_key_field() {
2865
+		if ($this->_primary_key_field === NULL) {
2866
+			foreach ($this->field_settings(TRUE) as $field_obj) {
2867
+				if ($this->is_primary_key_field($field_obj)) {
2868 2868
 					$this->_primary_key_field = $field_obj;
2869 2869
 					break;
2870 2870
 				}
2871 2871
 			}
2872
-			if( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base ){
2873
-				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s",'event_espresso'),get_class($this)));
2872
+			if ( ! $this->_primary_key_field instanceof EE_Primary_Key_Field_Base) {
2873
+				throw new EE_Error(sprintf(__("There is no Primary Key defined on model %s", 'event_espresso'), get_class($this)));
2874 2874
 			}
2875 2875
 		}
2876 2876
 		return $this->_primary_key_field;
@@ -2883,12 +2883,12 @@  discard block
 block discarded – undo
2883 2883
 	 * Internally does some caching.
2884 2884
 	 * @return boolean
2885 2885
 	 */
2886
-	public function has_primary_key_field(){
2887
-		if($this->_has_primary_key_field === null){
2888
-			try{
2886
+	public function has_primary_key_field() {
2887
+		if ($this->_has_primary_key_field === null) {
2888
+			try {
2889 2889
 				$this->get_primary_key_field();
2890 2890
 				$this->_has_primary_key_field = true;
2891
-			}catch(EE_Error $e){
2891
+			} catch (EE_Error $e) {
2892 2892
 				$this->_has_primary_key_field = false;
2893 2893
 			}
2894 2894
 		}
@@ -2902,9 +2902,9 @@  discard block
 block discarded – undo
2902 2902
 	 * @param string $field_class_name class name of field that you want to find. Eg, EE_Datetime_Field, EE_Foreign_Key_Field, etc
2903 2903
 	 * @return EE_Model_Field_Base or null if none is found
2904 2904
 	 */
2905
-	public function get_a_field_of_type($field_class_name){
2906
-		foreach($this->field_settings() as $field){
2907
-			if( $field instanceof $field_class_name ){
2905
+	public function get_a_field_of_type($field_class_name) {
2906
+		foreach ($this->field_settings() as $field) {
2907
+			if ($field instanceof $field_class_name) {
2908 2908
 				return $field;
2909 2909
 			}
2910 2910
 		}
@@ -2918,21 +2918,21 @@  discard block
 block discarded – undo
2918 2918
 	 * @return EE_Foreign_Key_Field_Base
2919 2919
 	 * @throws EE_Error
2920 2920
 	 */
2921
-	public function get_foreign_key_to($model_name){
2922
-		if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
2923
-			foreach($this->field_settings() as $field){
2921
+	public function get_foreign_key_to($model_name) {
2922
+		if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
2923
+			foreach ($this->field_settings() as $field) {
2924 2924
 //				if(is_subclass_of($field, 'EE_Foreign_Key_Field_Base')){
2925
-				if( $field instanceof EE_Foreign_Key_Field_Base ){
2926
-					if (in_array($model_name,$field->get_model_names_pointed_to() ) ) {
2927
-						$this->_cache_foreign_key_to_fields[ $model_name ] = $field;
2925
+				if ($field instanceof EE_Foreign_Key_Field_Base) {
2926
+					if (in_array($model_name, $field->get_model_names_pointed_to())) {
2927
+						$this->_cache_foreign_key_to_fields[$model_name] = $field;
2928 2928
 					}
2929 2929
 				}
2930 2930
 			}
2931
-			if( ! isset( $this->_cache_foreign_key_to_fields[ $model_name ] ) ){
2932
-				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s",'event_espresso'),$model_name,get_class($this)));
2931
+			if ( ! isset($this->_cache_foreign_key_to_fields[$model_name])) {
2932
+				throw new EE_Error(sprintf(__("There is no foreign key field pointing to model %s on model %s", 'event_espresso'), $model_name, get_class($this)));
2933 2933
 			}
2934 2934
 		}
2935
-		return $this->_cache_foreign_key_to_fields[ $model_name ];
2935
+		return $this->_cache_foreign_key_to_fields[$model_name];
2936 2936
 	}
2937 2937
 
2938 2938
 
@@ -2943,7 +2943,7 @@  discard block
 block discarded – undo
2943 2943
 	 * a table alias with a model chain prefix, like 'Venue__Event_Venue___Event_Meta'. Either one works
2944 2944
 	 * @return EE_Table_Base
2945 2945
 	 */
2946
-	function get_table_for_alias($table_alias){
2946
+	function get_table_for_alias($table_alias) {
2947 2947
 		$table_alias_sans_model_relation_chain_prefix = EE_Model_Parser::remove_table_alias_model_relation_chain_prefix($table_alias);
2948 2948
 		return $this->_tables[$table_alias_sans_model_relation_chain_prefix]->get_table_name();
2949 2949
 	}
@@ -2956,25 +2956,25 @@  discard block
 block discarded – undo
2956 2956
 	 * @param bool $include_db_only_fields flag indicating whether or not to include the db-only fields
2957 2957
 	 * @return EE_Model_Field_Base[] where the keys are the field's name
2958 2958
 	 */
2959
-	public function field_settings($include_db_only_fields = false){
2960
-		if( $include_db_only_fields ){
2961
-			if( $this->_cached_fields === NULL ){
2959
+	public function field_settings($include_db_only_fields = false) {
2960
+		if ($include_db_only_fields) {
2961
+			if ($this->_cached_fields === NULL) {
2962 2962
 				$this->_cached_fields = array();
2963
-				foreach($this->_fields as $fields_corresponding_to_table){
2964
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
2965
-						$this->_cached_fields[$field_name]=$field_obj;
2963
+				foreach ($this->_fields as $fields_corresponding_to_table) {
2964
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
2965
+						$this->_cached_fields[$field_name] = $field_obj;
2966 2966
 					}
2967 2967
 				}
2968 2968
 			}
2969 2969
 			return $this->_cached_fields;
2970
-		}else{
2971
-			if( $this->_cached_fields_non_db_only === NULL ){
2970
+		} else {
2971
+			if ($this->_cached_fields_non_db_only === NULL) {
2972 2972
 				$this->_cached_fields_non_db_only = array();
2973
-				foreach($this->_fields as $fields_corresponding_to_table){
2974
-					foreach($fields_corresponding_to_table as $field_name => $field_obj){
2973
+				foreach ($this->_fields as $fields_corresponding_to_table) {
2974
+					foreach ($fields_corresponding_to_table as $field_name => $field_obj) {
2975 2975
 						/** @var $field_obj EE_Model_Field_Base */
2976
-						if( ! $field_obj->is_db_only_field() ){
2977
-							$this->_cached_fields_non_db_only[$field_name]=$field_obj;
2976
+						if ( ! $field_obj->is_db_only_field()) {
2977
+							$this->_cached_fields_non_db_only[$field_name] = $field_obj;
2978 2978
 						}
2979 2979
 					}
2980 2980
 				}
@@ -2992,40 +2992,40 @@  discard block
 block discarded – undo
2992 2992
 	* 		@param		array		$rows of results of $wpdb->get_results($query,ARRAY_A)
2993 2993
 	*		@return 	EE_Base_Class[]		array keys are primary keys (if there is a primary key on the model. if not, numerically indexed)
2994 2994
 	*/
2995
-	protected function _create_objects( $rows = array() ) {
2996
-		$array_of_objects=array();
2997
-		if(empty($rows)){
2995
+	protected function _create_objects($rows = array()) {
2996
+		$array_of_objects = array();
2997
+		if (empty($rows)) {
2998 2998
 			return array();
2999 2999
 		}
3000 3000
 		$count_if_model_has_no_primary_key = 0;
3001
-		foreach ( $rows as $row ) {
3002
-			if(empty($row)){//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3001
+		foreach ($rows as $row) {
3002
+			if (empty($row)) {//wp did its weird thing where it returns an array like array(0=>null), which is totally not helpful...
3003 3003
 				return array();
3004 3004
 			}
3005
-			$classInstance=$this->instantiate_class_from_array_or_object($row);
3006
-			if( ! $classInstance ) {
3007
-				throw new EE_Error( sprintf( __( 'Could not create instance of class %s from row %s', 'event_espresso' ), $this->get_this_model_name(), http_build_query( $row ) ) );
3005
+			$classInstance = $this->instantiate_class_from_array_or_object($row);
3006
+			if ( ! $classInstance) {
3007
+				throw new EE_Error(sprintf(__('Could not create instance of class %s from row %s', 'event_espresso'), $this->get_this_model_name(), http_build_query($row)));
3008 3008
 			}
3009 3009
 			//set the timezone on the instantiated objects
3010
-			$classInstance->set_timezone( $this->_timezone );
3010
+			$classInstance->set_timezone($this->_timezone);
3011 3011
 			//make sure if there is any timezone setting present that we set the timezone for the object
3012
-			$array_of_objects[$this->has_primary_key_field() ? $classInstance->ID() : $count_if_model_has_no_primary_key++]=$classInstance;
3012
+			$array_of_objects[$this->has_primary_key_field() ? $classInstance->ID() : $count_if_model_has_no_primary_key++] = $classInstance;
3013 3013
 			//also, for all the relations of type BelongsTo, see if we can cache
3014 3014
 			//those related models
3015 3015
 			//(we could do this for other relations too, but if there are conditions
3016 3016
 			//that filtered out some fo the results, then we'd be caching an incomplete set
3017 3017
 			//so it requires a little more thought than just caching them immediately...)
3018
-			foreach($this->_model_relations as $modelName => $relation_obj){
3019
-				if( $relation_obj instanceof EE_Belongs_To_Relation){
3018
+			foreach ($this->_model_relations as $modelName => $relation_obj) {
3019
+				if ($relation_obj instanceof EE_Belongs_To_Relation) {
3020 3020
 					//check if this model's INFO is present. If so, cache it on the model
3021 3021
 					$other_model = $relation_obj->get_other_model();
3022 3022
 
3023 3023
 					$other_model_obj_maybe = $other_model->instantiate_class_from_array_or_object($row);
3024 3024
 
3025 3025
 					//if we managed to make a model object from the results, cache it on the main model object
3026
-					if( $other_model_obj_maybe ){
3026
+					if ($other_model_obj_maybe) {
3027 3027
 						//set timezone on these other model objects if they are present
3028
-						$other_model_obj_maybe->set_timezone( $this->_timezone );
3028
+						$other_model_obj_maybe->set_timezone($this->_timezone);
3029 3029
 						$classInstance->cache($modelName, $other_model_obj_maybe);
3030 3030
 					}
3031 3031
 				}
@@ -3046,12 +3046,12 @@  discard block
 block discarded – undo
3046 3046
 
3047 3047
 		$this_model_fields_and_values = array();
3048 3048
 		//setup the row using default values;
3049
-		foreach ( $this->field_settings() as $field_name => $field_obj ) {
3049
+		foreach ($this->field_settings() as $field_name => $field_obj) {
3050 3050
 			$this_model_fields_and_values[$field_name] = $field_obj->get_default_value();
3051 3051
 		}
3052 3052
 
3053 3053
 		$className = $this->_get_class_name();
3054
-		$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_and_values ), FALSE, FALSE );
3054
+		$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_and_values), FALSE, FALSE);
3055 3055
 
3056 3056
 		return $classInstance;
3057 3057
 	}
@@ -3062,13 +3062,13 @@  discard block
 block discarded – undo
3062 3062
 	 * _get_cached_acceptable_table_columns
3063 3063
 	 * @return EE_Model_Field_Base[]|null
3064 3064
 	 */
3065
-	private function _get_cached_acceptable_table_columns(){
3066
-		if( $this->_model_fields_sorted_by_db_col === NULL ){
3067
-			foreach( $this->field_settings() as $field_obj ){
3068
-				if( ! $field_obj->is_db_only_field() ){
3069
-					$this->_model_fields_sorted_by_db_col[ $field_obj->get_qualified_column() ] = $field_obj;
3065
+	private function _get_cached_acceptable_table_columns() {
3066
+		if ($this->_model_fields_sorted_by_db_col === NULL) {
3067
+			foreach ($this->field_settings() as $field_obj) {
3068
+				if ( ! $field_obj->is_db_only_field()) {
3069
+					$this->_model_fields_sorted_by_db_col[$field_obj->get_qualified_column()] = $field_obj;
3070 3070
 //					$this->_model_fields_sorted_by_db_col[ $field->get_table_column() ] = $field_obj;
3071
-					$this->_model_fields_sorted_by_db_col[ $field_obj->get_table_column() ] = $field_obj;
3071
+					$this->_model_fields_sorted_by_db_col[$field_obj->get_table_column()] = $field_obj;
3072 3072
 				}
3073 3073
 			}
3074 3074
 		}
@@ -3081,45 +3081,45 @@  discard block
 block discarded – undo
3081 3081
 	 * or an stdClass where each property is the name of a column,
3082 3082
 	 * @return EE_Base_Class
3083 3083
 	 */
3084
-	public function instantiate_class_from_array_or_object($cols_n_values){
3085
-		if( ! is_array( $cols_n_values ) && is_object( $cols_n_values )) {
3086
-			$cols_n_values = get_object_vars( $cols_n_values );
3084
+	public function instantiate_class_from_array_or_object($cols_n_values) {
3085
+		if ( ! is_array($cols_n_values) && is_object($cols_n_values)) {
3086
+			$cols_n_values = get_object_vars($cols_n_values);
3087 3087
 		}
3088 3088
 		$primary_key = NULL;
3089 3089
 		//make sure the array only has keys that are fields/columns on this model
3090
-		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3091
-		if( $this->has_primary_key_field() && isset( $this_model_fields_n_values[ $this->primary_key_name() ] ) ){
3092
-			$primary_key = $this_model_fields_n_values[ $this->primary_key_name() ];
3090
+		$this_model_fields_n_values = $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3091
+		if ($this->has_primary_key_field() && isset($this_model_fields_n_values[$this->primary_key_name()])) {
3092
+			$primary_key = $this_model_fields_n_values[$this->primary_key_name()];
3093 3093
 		}
3094
-		$className=$this->_get_class_name();
3094
+		$className = $this->_get_class_name();
3095 3095
 
3096 3096
 		//check we actually found results that we can use to build our model object
3097 3097
 		//if not, return null
3098
-		if( $this->has_primary_key_field()){
3099
-			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3098
+		if ($this->has_primary_key_field()) {
3099
+			if (empty($this_model_fields_n_values[$this->primary_key_name()])) {
3100 3100
 				return NULL;
3101 3101
 			}
3102
-		}else if($this->unique_indexes()){
3102
+		} else if ($this->unique_indexes()) {
3103 3103
 			$first_column = reset($this_model_fields_n_values);
3104
-			if(empty($first_column)){
3104
+			if (empty($first_column)) {
3105 3105
 				return NULL;
3106 3106
 			}
3107 3107
 		}
3108 3108
 
3109 3109
 		// if there is no primary key or the object doesn't already exist in the entity map, then create a new instance
3110
-		if ( $primary_key){
3111
-			$classInstance = $this->get_from_entity_map( $primary_key );
3112
-			if( ! $classInstance) {
3113
-				$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3110
+		if ($primary_key) {
3111
+			$classInstance = $this->get_from_entity_map($primary_key);
3112
+			if ( ! $classInstance) {
3113
+				$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3114 3114
 				// add this new object to the entity map
3115
-				$classInstance = $this->add_to_entity_map( $classInstance );
3115
+				$classInstance = $this->add_to_entity_map($classInstance);
3116 3116
 			}
3117
-		}else{
3118
-			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3117
+		} else {
3118
+			$classInstance = EE_Registry::instance()->load_class($className, array($this_model_fields_n_values, $this->_timezone), TRUE, FALSE);
3119 3119
 		}
3120 3120
 
3121 3121
 			//it is entirely possible that the instantiated class object has a set timezone_string db field and has set it's internal _timezone property accordingly (see new_instance_from_db in model objects particularly EE_Event for example).  In this case, we want to make sure the model object doesn't have its timezone string overwritten by any timezone property currently set here on the model so, we intentionally override the model _timezone property with the model_object timezone property.
3122
-		$this->set_timezone( $classInstance->get_timezone() );
3122
+		$this->set_timezone($classInstance->get_timezone());
3123 3123
 		return $classInstance;
3124 3124
 	}
3125 3125
 	/**
@@ -3127,8 +3127,8 @@  discard block
 block discarded – undo
3127 3127
 	 * @param int|string $id the ID of the model object
3128 3128
 	 * @return EE_Base_Class
3129 3129
 	 */
3130
-	public function get_from_entity_map( $id ){
3131
-		return isset( $this->_entity_map[ $id ] ) ? $this->_entity_map[ $id ] : NULL;
3130
+	public function get_from_entity_map($id) {
3131
+		return isset($this->_entity_map[$id]) ? $this->_entity_map[$id] : NULL;
3132 3132
 	}
3133 3133
 
3134 3134
 
@@ -3147,21 +3147,21 @@  discard block
 block discarded – undo
3147 3147
 	 * @throws EE_Error
3148 3148
 	 * @return \EE_Base_Class
3149 3149
 	 */
3150
-	public function add_to_entity_map( EE_Base_Class $object) {
3150
+	public function add_to_entity_map(EE_Base_Class $object) {
3151 3151
 		$className = $this->_get_class_name();
3152
-		if( ! $object instanceof $className ){
3153
-			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"),is_object( $object ) ? get_class( $object ) : $object, $className ) );
3152
+		if ( ! $object instanceof $className) {
3153
+			throw new EE_Error(sprintf(__("You tried adding a %s to a mapping of %ss", "event_espresso"), is_object($object) ? get_class($object) : $object, $className));
3154 3154
 		}
3155 3155
 		/** @var $object EE_Base_Class */
3156
-		if ( ! $object->ID() ){
3157
-			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"),get_class($this)));
3156
+		if ( ! $object->ID()) {
3157
+			throw new EE_Error(sprintf(__("You tried storing a model object with NO ID in the %s entity mapper.", "event_espresso"), get_class($this)));
3158 3158
 		}
3159 3159
 		// double check it's not already there
3160
-		$classInstance = $this->get_from_entity_map( $object->ID() );
3161
-		if ( $classInstance ) {
3160
+		$classInstance = $this->get_from_entity_map($object->ID());
3161
+		if ($classInstance) {
3162 3162
 			return $classInstance;
3163 3163
 		} else {
3164
-			$this->_entity_map[ $object->ID() ] = $object;
3164
+			$this->_entity_map[$object->ID()] = $object;
3165 3165
 			return $object;
3166 3166
 		}
3167 3167
 	}
@@ -3174,8 +3174,8 @@  discard block
 block discarded – undo
3174 3174
 	 * @param array $cols_n_values
3175 3175
 	 * @return array
3176 3176
 	 */
3177
-	public function deduce_fields_n_values_from_cols_n_values( $cols_n_values ) {
3178
-		return $this->_deduce_fields_n_values_from_cols_n_values( $cols_n_values );
3177
+	public function deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3178
+		return $this->_deduce_fields_n_values_from_cols_n_values($cols_n_values);
3179 3179
 	}
3180 3180
 
3181 3181
 
@@ -3188,38 +3188,38 @@  discard block
 block discarded – undo
3188 3188
 	 * @param string $cols_n_values
3189 3189
 	 * @return array
3190 3190
 	 */
3191
-	protected function _deduce_fields_n_values_from_cols_n_values( $cols_n_values ){
3191
+	protected function _deduce_fields_n_values_from_cols_n_values($cols_n_values) {
3192 3192
 		$this_model_fields_n_values = array();
3193
-		foreach( $this->get_tables() as $table_alias => $table_obj ) {
3194
-			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column() );
3193
+		foreach ($this->get_tables() as $table_alias => $table_obj) {
3194
+			$table_pk_value = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $table_obj->get_fully_qualified_pk_column(), $table_obj->get_pk_column());
3195 3195
 			//there is a primary key on this table and its not set. Use defaults for all its columns
3196
-			if( $table_obj->get_pk_column() && $table_pk_value === NULL ){
3197
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3198
-					if( ! $field_obj->is_db_only_field() ){
3196
+			if ($table_obj->get_pk_column() && $table_pk_value === NULL) {
3197
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3198
+					if ( ! $field_obj->is_db_only_field()) {
3199 3199
 						$this_model_fields_n_values[$field_name] = $field_obj->get_default_value();
3200 3200
 					}
3201 3201
 				}
3202
-			}else{
3202
+			} else {
3203 3203
 				//the table's rows existed. Use their values
3204
-				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3205
-					if( ! $field_obj->is_db_only_field() )
3206
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3204
+				foreach ($this->_get_fields_for_table($table_alias) as $field_name => $field_obj) {
3205
+					if ( ! $field_obj->is_db_only_field())
3206
+					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column());
3207 3207
 				}
3208 3208
 			}
3209 3209
 		}
3210 3210
 		return $this_model_fields_n_values;
3211 3211
 	}
3212 3212
 
3213
-	protected function _get_column_value_with_table_alias_or_not( $cols_n_values, $qualified_column, $regular_column ){
3213
+	protected function _get_column_value_with_table_alias_or_not($cols_n_values, $qualified_column, $regular_column) {
3214 3214
 		//ask the field what it think it's table_name.column_name should be, and call it the "qualified column"
3215 3215
 		//does the field on the model relate to this column retrieved from the db?
3216 3216
 		//or is it a db-only field? (not relating to the model)
3217
-		if( isset( $cols_n_values[ $qualified_column ] ) ){
3218
-			$value = $cols_n_values[ $qualified_column ];
3217
+		if (isset($cols_n_values[$qualified_column])) {
3218
+			$value = $cols_n_values[$qualified_column];
3219 3219
 
3220
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3221
-			$value = $cols_n_values[ $regular_column ];
3222
-		}else{
3220
+		}elseif (isset($cols_n_values[$regular_column])) {
3221
+			$value = $cols_n_values[$regular_column];
3222
+		} else {
3223 3223
 			$value = NULL;
3224 3224
 		}
3225 3225
 
@@ -3237,23 +3237,23 @@  discard block
 block discarded – undo
3237 3237
 	 * @param int|string $id
3238 3238
 	 * @return EE_Base_Class
3239 3239
 	 */
3240
-	public function refresh_entity_map_from_db( $id ){
3241
-		$obj_in_map = $this->get_from_entity_map( $id );
3242
-		if( $obj_in_map ){
3243
-			$wpdb_results = $this->_get_all_wpdb_results( array( array ( $this->get_primary_key_field()->get_name() => $id ), 'limit' => 1 ) );
3244
-			if( $wpdb_results && is_array( $wpdb_results ) ){
3245
-				$one_row = reset( $wpdb_results );
3246
-				foreach( $this->_deduce_fields_n_values_from_cols_n_values($one_row ) as $field_name => $db_value ) {
3247
-					$obj_in_map->set_from_db( $field_name, $db_value );
3240
+	public function refresh_entity_map_from_db($id) {
3241
+		$obj_in_map = $this->get_from_entity_map($id);
3242
+		if ($obj_in_map) {
3243
+			$wpdb_results = $this->_get_all_wpdb_results(array(array($this->get_primary_key_field()->get_name() => $id), 'limit' => 1));
3244
+			if ($wpdb_results && is_array($wpdb_results)) {
3245
+				$one_row = reset($wpdb_results);
3246
+				foreach ($this->_deduce_fields_n_values_from_cols_n_values($one_row) as $field_name => $db_value) {
3247
+					$obj_in_map->set_from_db($field_name, $db_value);
3248 3248
 				}
3249 3249
 				//clear the cache of related model objects
3250
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3251
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3250
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3251
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3252 3252
 				}
3253 3253
 			}
3254 3254
 			return $obj_in_map;
3255
-		}else{
3256
-			return $this->get_one_by_ID( $id );
3255
+		} else {
3256
+			return $this->get_one_by_ID($id);
3257 3257
 		}
3258 3258
 	}
3259 3259
 
@@ -3271,24 +3271,24 @@  discard block
 block discarded – undo
3271 3271
 	 * @param EE_Base_Class $replacing_model_obj
3272 3272
 	 * @return \EE_Base_Class
3273 3273
 	 */
3274
-	public function refresh_entity_map_with( $id, $replacing_model_obj ) {
3275
-		$obj_in_map = $this->get_from_entity_map( $id );
3276
-		if( $obj_in_map ){
3277
-			if( $replacing_model_obj instanceof EE_Base_Class ){
3278
-				foreach( $replacing_model_obj->model_field_array() as $field_name => $value ) {
3279
-					$obj_in_map->set( $field_name, $value );
3274
+	public function refresh_entity_map_with($id, $replacing_model_obj) {
3275
+		$obj_in_map = $this->get_from_entity_map($id);
3276
+		if ($obj_in_map) {
3277
+			if ($replacing_model_obj instanceof EE_Base_Class) {
3278
+				foreach ($replacing_model_obj->model_field_array() as $field_name => $value) {
3279
+					$obj_in_map->set($field_name, $value);
3280 3280
 				}
3281 3281
 				//make the model object in the entity map's cache match the $replacing_model_obj
3282
-				foreach ( $this->relation_settings() as $relation_name => $relation_obj ){
3283
-					$obj_in_map->clear_cache($relation_name, NULL, TRUE );
3284
-					foreach( $replacing_model_obj->get_all_from_cache( $relation_name ) as $cache_id => $cached_obj ) {
3285
-						$obj_in_map->cache( $relation_name, $cached_obj, $cache_id );
3282
+				foreach ($this->relation_settings() as $relation_name => $relation_obj) {
3283
+					$obj_in_map->clear_cache($relation_name, NULL, TRUE);
3284
+					foreach ($replacing_model_obj->get_all_from_cache($relation_name) as $cache_id => $cached_obj) {
3285
+						$obj_in_map->cache($relation_name, $cached_obj, $cache_id);
3286 3286
 					}
3287 3287
 				}
3288 3288
 			}
3289 3289
 			return $obj_in_map;
3290
-		}else{
3291
-			$this->add_to_entity_map( $replacing_model_obj );
3290
+		} else {
3291
+			$this->add_to_entity_map($replacing_model_obj);
3292 3292
 			return $replacing_model_obj;
3293 3293
 		}
3294 3294
 	}
@@ -3301,7 +3301,7 @@  discard block
 block discarded – undo
3301 3301
 	 * require_once($this->_getClassName().".class.php");
3302 3302
 	 * @return string
3303 3303
 	 */
3304
-	private function _get_class_name(){
3304
+	private function _get_class_name() {
3305 3305
 		return "EE_".$this->get_this_model_name();
3306 3306
 	}
3307 3307
 
@@ -3314,10 +3314,10 @@  discard block
 block discarded – undo
3314 3314
 	 * @param int $quantity
3315 3315
 	 * @return string
3316 3316
 	 */
3317
-	public function item_name($quantity = 1){
3318
-		if($quantity == 1){
3317
+	public function item_name($quantity = 1) {
3318
+		if ($quantity == 1) {
3319 3319
 			return $this->singular_item;
3320
-		}else{
3320
+		} else {
3321 3321
 			return $this->plural_item;
3322 3322
 		}
3323 3323
 	}
@@ -3346,13 +3346,13 @@  discard block
 block discarded – undo
3346 3346
 	 * @throws EE_Error
3347 3347
 	 * @return mixed whatever the plugin which calls add_filter decides
3348 3348
 	 */
3349
-	public function __call($methodName,$args){
3350
-		$className=get_class($this);
3351
-		$tagName="FHEE__{$className}__{$methodName}";
3352
-		if(!has_filter($tagName)){
3349
+	public function __call($methodName, $args) {
3350
+		$className = get_class($this);
3351
+		$tagName = "FHEE__{$className}__{$methodName}";
3352
+		if ( ! has_filter($tagName)) {
3353 3353
 			throw new EE_Error(
3354 3354
 				sprintf(
3355
-					__( 'Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso' ),
3355
+					__('Method %1$s on model %2$s does not exist! You can create one with the following code in functions.php or in a plugin: %4$s function my_callback(%4$s \$previousReturnValue, EEM_Base \$object\ $argsArray=NULL ){%4$s     /*function body*/%4$s      return \$whatever;%4$s }%4$s add_filter( \'%3$s\', \'my_callback\', 10, 3 );', 'event_espresso'),
3356 3356
 					$methodName,
3357 3357
 					$className,
3358 3358
 					$tagName,
@@ -3361,7 +3361,7 @@  discard block
 block discarded – undo
3361 3361
 			);
3362 3362
 		}
3363 3363
 
3364
-		return apply_filters($tagName,null,$this,$args);
3364
+		return apply_filters($tagName, null, $this, $args);
3365 3365
 	}
3366 3366
 
3367 3367
 
@@ -3374,22 +3374,22 @@  discard block
 block discarded – undo
3374 3374
 	 * @throws EE_Error
3375 3375
 	 * @return EE_Base_Class
3376 3376
 	 */
3377
-	public function ensure_is_obj( $base_class_obj_or_id, $ensure_is_in_db = FALSE ){
3377
+	public function ensure_is_obj($base_class_obj_or_id, $ensure_is_in_db = FALSE) {
3378 3378
 		$className = $this->_get_class_name();
3379 3379
 		$primary_key_field = $this->get_primary_key_field();
3380
-		if( $base_class_obj_or_id instanceof $className ){
3380
+		if ($base_class_obj_or_id instanceof $className) {
3381 3381
 			$model_object = $base_class_obj_or_id;
3382
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
3383
-				is_int( $base_class_obj_or_id ) ||
3384
-				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
3382
+		}elseif ($primary_key_field instanceof EE_Primary_Key_Int_Field && (
3383
+				is_int($base_class_obj_or_id) ||
3384
+				is_string($base_class_obj_or_id) )) {//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
3385 3385
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3386
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
3386
+		}elseif ($primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id)) {
3387 3387
 			//assume its a string representation of the object
3388 3388
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3389
-		}else{
3390
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
3389
+		} else {
3390
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
3391 3391
 		}
3392
-		if( $model_object->ID() == NULL && $ensure_is_in_db){
3392
+		if ($model_object->ID() == NULL && $ensure_is_in_db) {
3393 3393
 			$model_object->save();
3394 3394
 		}
3395 3395
 		return $model_object;
@@ -3405,19 +3405,19 @@  discard block
 block discarded – undo
3405 3405
 	 * @return int|string depending on the type of this model object's ID
3406 3406
 	 * @throws EE_Error
3407 3407
 	 */
3408
-	public function ensure_is_ID($base_class_obj_or_id){
3408
+	public function ensure_is_ID($base_class_obj_or_id) {
3409 3409
 		$className = $this->_get_class_name();
3410
-		if( $base_class_obj_or_id instanceof $className ){
3410
+		if ($base_class_obj_or_id instanceof $className) {
3411 3411
 			/** @var $base_class_obj_or_id EE_Base_Class */
3412 3412
 			$id = $base_class_obj_or_id->ID();
3413
-		}elseif(is_int($base_class_obj_or_id)){
3413
+		}elseif (is_int($base_class_obj_or_id)) {
3414 3414
 			//assume it's an ID
3415 3415
 			$id = $base_class_obj_or_id;
3416
-		}elseif(is_string($base_class_obj_or_id)){
3416
+		}elseif (is_string($base_class_obj_or_id)) {
3417 3417
 			//assume its a string representation of the object
3418 3418
 			$id = $base_class_obj_or_id;
3419
-		}else{
3420
-			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
3419
+		} else {
3420
+			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'", 'event_espresso'), $base_class_obj_or_id, $this->_get_class_name(), print_r($base_class_obj_or_id, true)));
3421 3421
 		}
3422 3422
 		return $id;
3423 3423
 	}
@@ -3440,14 +3440,14 @@  discard block
 block discarded – undo
3440 3440
 	 * @param int $values_already_prepared like one of the constants on EEM_Base
3441 3441
 	 * @return void
3442 3442
 	 */
3443
-	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object){
3443
+	public function assume_values_already_prepared_by_model_object($values_already_prepared = self::not_prepared_by_model_object) {
3444 3444
 		$this->_values_already_prepared_by_model_object = $values_already_prepared;
3445 3445
 	}
3446 3446
 	/**
3447 3447
 	 * Read comments for assume_values_already_prepared_by_model_object()
3448 3448
 	 * @return int
3449 3449
 	 */
3450
-	public function get_assumption_concerning_values_already_prepared_by_model_object(){
3450
+	public function get_assumption_concerning_values_already_prepared_by_model_object() {
3451 3451
 		return $this->_values_already_prepared_by_model_object;
3452 3452
 	}
3453 3453
 
@@ -3455,17 +3455,17 @@  discard block
 block discarded – undo
3455 3455
 	 * Gets all the indexes on this model
3456 3456
 	 * @return EE_Index[]
3457 3457
 	 */
3458
-	public function indexes(){
3458
+	public function indexes() {
3459 3459
 		return $this->_indexes;
3460 3460
 	}
3461 3461
 	/**
3462 3462
 	 * Gets all the Unique Indexes on this model
3463 3463
 	 * @return EE_Unique_Index[]
3464 3464
 	 */
3465
-	public function unique_indexes(){
3465
+	public function unique_indexes() {
3466 3466
 		$unique_indexes = array();
3467
-		foreach($this->_indexes as $name => $index){
3468
-			if($index instanceof EE_Unique_Index){
3467
+		foreach ($this->_indexes as $name => $index) {
3468
+			if ($index instanceof EE_Unique_Index) {
3469 3469
 				$unique_indexes [$name] = $index;
3470 3470
 			}
3471 3471
 		}
@@ -3478,9 +3478,9 @@  discard block
 block discarded – undo
3478 3478
 	 * on a primary index
3479 3479
 	 * @return EE_Model_Field_Base[]
3480 3480
 	 */
3481
-	public function get_combined_primary_key_fields(){
3482
-		foreach($this->indexes() as $index){
3483
-			if($index instanceof EE_Primary_Key_Index){
3481
+	public function get_combined_primary_key_fields() {
3482
+		foreach ($this->indexes() as $index) {
3483
+			if ($index instanceof EE_Primary_Key_Index) {
3484 3484
 				return $index->fields();
3485 3485
 			}
3486 3486
 		}
@@ -3493,7 +3493,7 @@  discard block
 block discarded – undo
3493 3493
 	 * @param array $cols_n_values keys are field names, values are their values
3494 3494
 	 * @return string
3495 3495
 	 */
3496
-	public function get_index_primary_key_string($cols_n_values){
3496
+	public function get_index_primary_key_string($cols_n_values) {
3497 3497
 		$cols_n_values_for_primary_key_index = array_intersect_key($cols_n_values, $this->get_combined_primary_key_fields());
3498 3498
 		return http_build_query($cols_n_values_for_primary_key_index);
3499 3499
 	}
@@ -3505,13 +3505,13 @@  discard block
 block discarded – undo
3505 3505
 	 * @param string $index_primary_key_string
3506 3506
 	 * @return null|array
3507 3507
 	 */
3508
-	function parse_index_primary_key_string( $index_primary_key_string) {
3508
+	function parse_index_primary_key_string($index_primary_key_string) {
3509 3509
 		$key_fields = $this->get_combined_primary_key_fields();
3510 3510
 		//check all of them are in the $id
3511 3511
 		$key_vals_in_combined_pk = array();
3512
-		parse_str( $index_primary_key_string, $key_vals_in_combined_pk );
3513
-		foreach( $key_fields as $key_field_name => $field_obj ) {
3514
-			if( ! isset( $key_vals_in_combined_pk[ $key_field_name ] ) ){
3512
+		parse_str($index_primary_key_string, $key_vals_in_combined_pk);
3513
+		foreach ($key_fields as $key_field_name => $field_obj) {
3514
+			if ( ! isset($key_vals_in_combined_pk[$key_field_name])) {
3515 3515
 				return NULL;
3516 3516
 			}
3517 3517
 		}
@@ -3524,10 +3524,10 @@  discard block
 block discarded – undo
3524 3524
 	 * @param array $key_vals
3525 3525
 	 * @return boolean
3526 3526
 	 */
3527
-	function has_all_combined_primary_key_fields( $key_vals ) {
3528
-		$keys_it_should_have = array_keys( $this->get_combined_primary_key_fields() );
3529
-		foreach( $keys_it_should_have as $key ){
3530
-			if( ! isset( $key_vals[ $key ] ) ){
3527
+	function has_all_combined_primary_key_fields($key_vals) {
3528
+		$keys_it_should_have = array_keys($this->get_combined_primary_key_fields());
3529
+		foreach ($keys_it_should_have as $key) {
3530
+			if ( ! isset($key_vals[$key])) {
3531 3531
 				return false;
3532 3532
 			}
3533 3533
 		}
@@ -3543,23 +3543,23 @@  discard block
 block discarded – undo
3543 3543
 	 * @throws EE_Error
3544 3544
 	 * @return \EE_Base_Class[]
3545 3545
 	 */
3546
-	public function get_all_copies($model_object_or_attributes_array, $query_params = array()){
3546
+	public function get_all_copies($model_object_or_attributes_array, $query_params = array()) {
3547 3547
 
3548
-		if($model_object_or_attributes_array instanceof EE_Base_Class){
3548
+		if ($model_object_or_attributes_array instanceof EE_Base_Class) {
3549 3549
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
3550
-		}elseif(is_array($model_object_or_attributes_array)){
3550
+		}elseif (is_array($model_object_or_attributes_array)) {
3551 3551
 			$attributes_array = $model_object_or_attributes_array;
3552
-		}else{
3553
-			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
3552
+		} else {
3553
+			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"), $model_object_or_attributes_array));
3554 3554
 		}
3555 3555
 		//even copies obviously won't have the same ID, so remove the primary key
3556 3556
 		//from the WHERE conditions for finding copies (if there is a primary key, of course)
3557
-		if($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])){
3557
+		if ($this->has_primary_key_field() && isset($attributes_array[$this->primary_key_name()])) {
3558 3558
 			unset($attributes_array[$this->primary_key_name()]);
3559 3559
 		}
3560
-		if(isset($query_params[0])){
3561
-			$query_params[0] = array_merge($attributes_array,$query_params);
3562
-		}else{
3560
+		if (isset($query_params[0])) {
3561
+			$query_params[0] = array_merge($attributes_array, $query_params);
3562
+		} else {
3563 3563
 			$query_params[0] = $attributes_array;
3564 3564
 		}
3565 3565
 		return $this->get_all($query_params);
@@ -3573,16 +3573,16 @@  discard block
 block discarded – undo
3573 3573
 	 * @param array $query_params
3574 3574
 	 * @return EE_Base_Class
3575 3575
 	 */
3576
-	function get_one_copy($model_object_or_attributes_array,$query_params = array()){
3577
-		if( ! is_array( $query_params ) ){
3578
-			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf( __( '$query_params should be an array, you passed a variable of type %s', 'event_espresso' ), gettype( $query_params ) ), '4.6.0' );
3576
+	function get_one_copy($model_object_or_attributes_array, $query_params = array()) {
3577
+		if ( ! is_array($query_params)) {
3578
+			EE_Error::doing_it_wrong('EEM_Base::get_one_copy', sprintf(__('$query_params should be an array, you passed a variable of type %s', 'event_espresso'), gettype($query_params)), '4.6.0');
3579 3579
 			$query_params = array();
3580 3580
 		}
3581 3581
 		$query_params['limit'] = 1;
3582
-		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
3583
-		if(is_array($copies)){
3582
+		$copies = $this->get_all_copies($model_object_or_attributes_array, $query_params);
3583
+		if (is_array($copies)) {
3584 3584
 			return array_shift($copies);
3585
-		}else{
3585
+		} else {
3586 3586
 			return null;
3587 3587
 		}
3588 3588
 	}
@@ -3596,10 +3596,10 @@  discard block
 block discarded – undo
3596 3596
 	 * @param int|string $id the value of the primary key to update
3597 3597
 	 * @return int number of rows updated
3598 3598
 	 */
3599
-	public function update_by_ID($fields_n_values,$id){
3599
+	public function update_by_ID($fields_n_values, $id) {
3600 3600
 		$query_params = array(0=>array($this->get_primary_key_field()->get_name() => $id),
3601 3601
 			'default_where_conditions'=>'other_models_only',);
3602
-		return $this->update($fields_n_values,$query_params);
3602
+		return $this->update($fields_n_values, $query_params);
3603 3603
 	}
3604 3604
 
3605 3605
 
@@ -3610,12 +3610,12 @@  discard block
 block discarded – undo
3610 3610
 	 * @return string an operator which can be used in SQL
3611 3611
 	 * @throws EE_Error
3612 3612
 	 */
3613
-	private function _prepare_operator_for_sql($operator_supplied){
3613
+	private function _prepare_operator_for_sql($operator_supplied) {
3614 3614
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
3615
-		if($sql_operator){
3615
+		if ($sql_operator) {
3616 3616
 			return $sql_operator;
3617
-		}else{
3618
-			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
3617
+		} else {
3618
+			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"), $operator_supplied, implode(",", array_keys($this->_valid_operators))));
3619 3619
 		}
3620 3620
 	}
3621 3621
 
@@ -3625,10 +3625,10 @@  discard block
 block discarded – undo
3625 3625
 	 * @param array $query_params like get_all's
3626 3626
 	 * @return string[]
3627 3627
 	 */
3628
-	public function get_all_names($query_params = array()){
3628
+	public function get_all_names($query_params = array()) {
3629 3629
 		$objs = $this->get_all($query_params);
3630 3630
 		$names = array();
3631
-		foreach($objs as $obj){
3631
+		foreach ($objs as $obj) {
3632 3632
 			$names[$obj->ID()] = $obj->name();
3633 3633
 		}
3634 3634
 		return $names;
Please login to merge, or discard this patch.
Braces   +123 added lines, -113 removed lines patch added patch discarded remove patch
@@ -430,8 +430,9 @@  discard block
 block discarded – undo
430 430
 	 * @return array
431 431
 	 */
432 432
 	 public function status_array( $translated = FALSE ) {
433
-	 	if ( !array_key_exists('Status', $this->_model_relations ) )
434
-	 		return array();
433
+	 	if ( !array_key_exists('Status', $this->_model_relations ) ) {
434
+	 		 		return array();
435
+	 	}
435 436
 	 	$model_name = $this->get_this_model_name();
436 437
 	 	$status_type = str_replace(' ', '_', strtolower( str_replace('_', ' ', $model_name) ) );
437 438
 	 	$stati = EEM_Status::instance()->get_all(array(array('STS_type' => $status_type) ) );
@@ -591,7 +592,7 @@  discard block
 block discarded – undo
591 592
 				$last_model_name = end( $models_to_follow_to_wp_users );
592 593
 				$model_with_fk_to_wp_users = EE_Registry::instance()->load_model( $last_model_name );
593 594
 				$model_chain_to_wp_user = $this->_model_chain_to_wp_user . '.';
594
-			}else{
595
+			} else{
595 596
 				$model_with_fk_to_wp_users = $this;
596 597
 				$model_chain_to_wp_user = '';
597 598
 			}
@@ -627,11 +628,11 @@  discard block
 block discarded – undo
627 628
 	public function is_owned() {
628 629
 		if( $this->model_chain_to_wp_user() ){
629 630
 			return true;
630
-		}else{
631
+		} else{
631 632
 			try{
632 633
 				$this->get_foreign_key_to( 'WP_User' );
633 634
 				return true;
634
-			}catch( EE_Error $e ){
635
+			} catch( EE_Error $e ){
635 636
 				return false;
636 637
 			}
637 638
 		}
@@ -654,9 +655,9 @@  discard block
 block discarded – undo
654 655
 		//remember the custom selections, if any
655 656
 		if(is_array($columns_to_select)){
656 657
 			$this->_custom_selections = $columns_to_select;
657
-		}elseif(is_string($columns_to_select)){
658
+		} elseif(is_string($columns_to_select)){
658 659
 			$this->_custom_selections = array($this->_custom_selections);
659
-		}else{
660
+		} else{
660 661
 			$this->_custom_selections = array();
661 662
 		}
662 663
 
@@ -707,7 +708,7 @@  discard block
 block discarded – undo
707 708
 				$select_sql_array[] = "{$selection_and_datatype[0]} AS $alias";
708 709
 			}
709 710
 			$columns_to_select_string = implode(", ",$select_sql_array);
710
-		}else{
711
+		} else{
711 712
 			$columns_to_select_string = $columns_to_select;
712 713
 		}
713 714
 		return $columns_to_select_string;
@@ -735,10 +736,10 @@  discard block
 block discarded – undo
735 736
 	function get_one_by_ID($id){
736 737
 		if( $this->get_from_entity_map( $id ) ){
737 738
 			return $this->get_from_entity_map( $id );
738
-		}elseif( $this->has_primary_key_field ( ) ) {
739
+		} elseif( $this->has_primary_key_field ( ) ) {
739 740
 			$primary_key_name = $this->get_primary_key_field()->get_name();
740 741
 			return $this->get_one(array(array($primary_key_name => $id)));
741
-		}else{
742
+		} else{
742 743
 			//no primary key, so the $id must be from the get_index_primary_key_string()
743 744
 			return $this->get_one( array( $this->parse_index_primary_key_string( $id ) ) );
744 745
 		}
@@ -760,7 +761,7 @@  discard block
 block discarded – undo
760 761
 		$items = $this->get_all($query_params);
761 762
 		if(empty($items)){
762 763
 			return null;
763
-		}else{
764
+		} else{
764 765
 			return array_shift($items);
765 766
 		}
766 767
 	}
@@ -856,7 +857,7 @@  discard block
 block discarded – undo
856 857
 				//get the model object's PK, as we'll want this if we need to insert a row into secondary tables
857 858
 				if( $this->has_primary_key_field() ){
858 859
 					$main_table_pk_value = $wpdb_result[ $this->get_primary_key_field()->get_qualified_column() ];
859
-				}else{
860
+				} else{
860 861
 					//if there's no primary key, we basically can't support having a 2nd table on the model (we could but it woudl be lots of work)
861 862
 					$main_table_pk_value = null;
862 863
 				}
@@ -891,7 +892,7 @@  discard block
 block discarded – undo
891 892
 		if( $keep_model_objs_in_sync && ! $this->_values_already_prepared_by_model_object ){
892 893
 			if( $this->has_primary_key_field() ){
893 894
 				$model_objs_affected_ids = $this->get_col( $query_params );
894
-			}else{
895
+			} else{
895 896
 				//we need to select a bunch of columns and then combine them into the the "index primary key string"s
896 897
 				$models_affected_key_columns = $this->_get_all_wpdb_results($query_params, ARRAY_A );
897 898
 				$model_objs_affected_ids = array();
@@ -951,9 +952,9 @@  discard block
 block discarded – undo
951 952
 
952 953
 		if( $field_to_select ){
953 954
 			$field = $this->field_settings_for( $field_to_select );
954
-		}elseif( $this->has_primary_key_field ( ) ){
955
+		} elseif( $this->has_primary_key_field ( ) ){
955 956
 			$field = $this->get_primary_key_field();
956
-		}else{
957
+		} else{
957 958
 			//no primary key, just grab the first column
958 959
 			$field = reset( $this->field_settings());
959 960
 		}
@@ -1044,7 +1045,7 @@  discard block
 block discarded – undo
1044 1045
 
1045 1046
 			//		/echo "delete sql:$SQL";
1046 1047
 			$rows_deleted = $this->_do_wpdb_query( 'query', array( $SQL ) );
1047
-		}else{
1048
+		} else{
1048 1049
 			$rows_deleted = 0;
1049 1050
 		}
1050 1051
 
@@ -1086,7 +1087,7 @@  discard block
 block discarded – undo
1086 1087
 		//first, if $ignore_this_model_obj was supplied, get its model
1087 1088
 		if($ignore_this_model_obj && $ignore_this_model_obj instanceof EE_Base_Class){
1088 1089
 			$ignored_model = $ignore_this_model_obj->get_model();
1089
-		}else{
1090
+		} else{
1090 1091
 			$ignored_model = null;
1091 1092
 		}
1092 1093
 		//now check all the relations of $this_model_obj_or_id and see if there
@@ -1099,7 +1100,7 @@  discard block
 block discarded – undo
1099 1100
 				if($ignored_model && $relation_name == $ignored_model->get_this_model_name()){
1100 1101
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id,array(
1101 1102
 					array($ignored_model->get_primary_key_field()->get_name() => array('!=',$ignore_this_model_obj->ID()))));
1102
-				}else{
1103
+				} else{
1103 1104
 					$related_model_objects = $relation_obj->get_all_related($this_model_obj_or_id);
1104 1105
 				}
1105 1106
 
@@ -1136,24 +1137,28 @@  discard block
 block discarded – undo
1136 1137
 				}
1137 1138
 
1138 1139
 				//primary table deletes
1139
-				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) )
1140
-					$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1140
+				if ( isset( $delete_object[$primary_table->get_fully_qualified_pk_column()] ) ) {
1141
+									$deletes[$primary_table->get_fully_qualified_pk_column()][] = $delete_object[$primary_table->get_fully_qualified_pk_column()];
1142
+				}
1141 1143
 
1142 1144
 				//other tables
1143 1145
 				if ( !empty( $other_tables ) ) {
1144 1146
 					foreach ( $other_tables as $ot ) {
1145 1147
 
1146 1148
 						//first check if we've got the foreign key column here.
1147
-						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) )
1148
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1149
+						if ( isset( $delete_object[$ot->get_fully_qualified_fk_column()] ) ) {
1150
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_fk_column()];
1151
+						}
1149 1152
 
1150 1153
 						//wait! it's entirely possible that we'll have a the primary key for this table in here if it's a foreign key for one of the other secondary tables
1151
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) )
1152
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1154
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_column()] ) ) {
1155
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1156
+						}
1153 1157
 
1154 1158
 						//finally, it is possible that the fk for this table is found in the fully qualified pk column for the fk table, so let's see if that's there!
1155
-						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) )
1156
-							$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1159
+						if ( isset( $delete_object[$ot->get_fully_qualified_pk_on_fk_table()]) ) {
1160
+													$deletes[$ot->get_fully_qualified_pk_column()][] = $delete_object[$ot->get_fully_qualified_pk_column()];
1161
+						}
1157 1162
 					}
1158 1163
 				}
1159 1164
 			}
@@ -1166,7 +1171,7 @@  discard block
 block discarded – undo
1166 1171
 			}
1167 1172
 
1168 1173
 			return !empty($query) ? implode(' AND ', $query ) : '';
1169
-		}elseif(count($this->get_combined_primary_key_fields()) > 1){
1174
+		} elseif(count($this->get_combined_primary_key_fields()) > 1){
1170 1175
 			$ways_to_identify_a_row = array();
1171 1176
 			$fields = $this->get_combined_primary_key_fields();
1172 1177
 			//note: because there' sno primary key, that means nothing else  can be pointing to this model, right?
@@ -1178,7 +1183,7 @@  discard block
 block discarded – undo
1178 1183
 				$ways_to_identify_a_row[] = "(".implode(" AND ",$values_for_each_cpk_for_a_row).")";
1179 1184
 			}
1180 1185
 			return implode(" OR ",$ways_to_identify_a_row);
1181
-		}else{
1186
+		} else{
1182 1187
 			//so there's no primary key and no combined key...
1183 1188
 			//sorry, can't help you
1184 1189
 			throw new EE_Error(sprintf(__("Cannot delete objects of type %s because there is no primary key NOR combined key", "event_espresso"),get_class($this)));
@@ -1200,10 +1205,10 @@  discard block
 block discarded – undo
1200 1205
 		if($field_to_count){
1201 1206
 			$field_obj = $this->field_settings_for($field_to_count);
1202 1207
 			$column_to_count = $field_obj->get_qualified_column();
1203
-		}elseif($this->has_primary_key_field ()){
1208
+		} elseif($this->has_primary_key_field ()){
1204 1209
 			$pk_field_obj = $this->get_primary_key_field();
1205 1210
 			$column_to_count = $pk_field_obj->get_qualified_column();
1206
-		}else{//there's no primary key
1211
+		} else{//there's no primary key
1207 1212
 			$column_to_count = '*';
1208 1213
 		}
1209 1214
 
@@ -1225,7 +1230,7 @@  discard block
 block discarded – undo
1225 1230
 		if($field_to_sum){
1226 1231
 			$field_obj = $this->field_settings_for($field_to_sum);
1227 1232
 
1228
-		}else{
1233
+		} else{
1229 1234
 			$field_obj = $this->get_primary_key_field();
1230 1235
 		}
1231 1236
 		$column_to_count = $field_obj->get_qualified_column();
@@ -1234,7 +1239,7 @@  discard block
 block discarded – undo
1234 1239
 		$return_value = $this->_do_wpdb_query('get_var',array( $SQL ) );
1235 1240
 		if($field_obj->get_wpdb_data_type() == '%d' || $field_obj->get_wpdb_data_type() == '%s' ){
1236 1241
 			return (int)$return_value;
1237
-		}else{//must be %f
1242
+		} else{//must be %f
1238 1243
 			return (float)$return_value;
1239 1244
 		}
1240 1245
 	}
@@ -1486,7 +1491,7 @@  discard block
 block discarded – undo
1486 1491
 		$results = $this->get_all_related($id_or_obj,$other_model_name,$query_params);
1487 1492
 		if( $results ){
1488 1493
 			return array_shift($results);
1489
-		}else{
1494
+		} else{
1490 1495
 			return null;
1491 1496
 		}
1492 1497
 
@@ -1555,7 +1560,7 @@  discard block
 block discarded – undo
1555 1560
 			 */
1556 1561
 			do_action( 'AHEE__EEM_Base__insert__end', $this, $field_n_values, $new_id );
1557 1562
 			return $new_id;
1558
-		}else{
1563
+		} else{
1559 1564
 			return FALSE;
1560 1565
 		}
1561 1566
 	}
@@ -1596,9 +1601,9 @@  discard block
 block discarded – undo
1596 1601
 	public function get_one_conflicting($obj_or_fields_array, $include_primary_key = true ){
1597 1602
 		if($obj_or_fields_array instanceof EE_Base_Class){
1598 1603
 			$fields_n_values = $obj_or_fields_array->model_field_array();
1599
-		}elseif( is_array($obj_or_fields_array)){
1604
+		} elseif( is_array($obj_or_fields_array)){
1600 1605
 			$fields_n_values = $obj_or_fields_array;
1601
-		}else{
1606
+		} else{
1602 1607
 			throw new EE_Error(sprintf(__("%s get_all_conflicting should be called with a model object or an array of field names and values, you provided %d", "event_espresso"),get_class($this),$obj_or_fields_array));
1603 1608
 		}
1604 1609
 		$query_params = array();
@@ -1614,7 +1619,7 @@  discard block
 block discarded – undo
1614 1619
 		//if there is nothing to base this search on, then we shouldn't find anything
1615 1620
 		if( empty( $query_params ) ){
1616 1621
 			return array();
1617
-		}else{
1622
+		} else{
1618 1623
 			return $this->get_one($query_params);
1619 1624
 		}
1620 1625
 	}
@@ -1684,12 +1689,12 @@  discard block
 block discarded – undo
1684 1689
 		if($this->has_primary_key_field()){
1685 1690
 			if($this->get_primary_key_field()->is_auto_increment()){
1686 1691
 				return $wpdb->insert_id;
1687
-			}else{
1692
+			} else{
1688 1693
 				//it's not an auto-increment primary key, so
1689 1694
 				//it must have been supplied
1690 1695
 				return $fields_n_values[$this->get_primary_key_field()->get_name()];
1691 1696
 			}
1692
-		}else{
1697
+		} else{
1693 1698
 			//we can't return a  primary key because there is none. instead return
1694 1699
 			//a unique string indicating this model
1695 1700
 			return $this->get_index_primary_key_string($fields_n_values);
@@ -1736,7 +1741,7 @@  discard block
 block discarded – undo
1736 1741
 					//leave the value alone
1737 1742
 			}
1738 1743
 			return $value;
1739
-		}else{
1744
+		} else{
1740 1745
 			return $value;
1741 1746
 		}
1742 1747
 	}
@@ -1829,7 +1834,7 @@  discard block
 block discarded – undo
1829 1834
 		if(array_key_exists('group_by', $query_params)){
1830 1835
 			if(is_array($query_params['group_by'])){
1831 1836
 				$this->_extract_related_models_from_sub_params_array_values($query_params['group_by'],$query_info_carrier,'group_by');
1832
-			}elseif( ! empty ( $query_params['group_by'] )){
1837
+			} elseif( ! empty ( $query_params['group_by'] )){
1833 1838
 				$this->_extract_related_model_info_from_query_param( $query_params['group_by'],$query_info_carrier,'group_by');
1834 1839
 			}
1835 1840
 		}
@@ -1837,10 +1842,11 @@  discard block
 block discarded – undo
1837 1842
 			$this->_extract_related_models_from_sub_params_array_keys($query_params[0], $query_info_carrier,'having');
1838 1843
 		}
1839 1844
 		if(array_key_exists('order_by', $query_params)){
1840
-			if ( is_array( $query_params['order_by'] ) )
1841
-				$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
1842
-			elseif( ! empty( $query_params['order_by'] ))
1843
-				$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
1845
+			if ( is_array( $query_params['order_by'] ) ) {
1846
+							$this->_extract_related_models_from_sub_params_array_keys($query_params['order_by'],$query_info_carrier,'order_by');
1847
+			} elseif( ! empty( $query_params['order_by'] )) {
1848
+							$this->_extract_related_model_info_from_query_param( $query_params['order_by'], $query_info_carrier,'order_by');
1849
+			}
1844 1850
 		}
1845 1851
 		if(array_key_exists('force_join', $query_params)){
1846 1852
 			$this->_extract_related_models_from_sub_params_array_values($query_params['force_join'],$query_info_carrier,'force_join');
@@ -1872,10 +1878,10 @@  discard block
 block discarded – undo
1872 1878
 					if (! is_array($possibly_array_of_params)){
1873 1879
 						throw new EE_Error(sprintf(__("You used a special where query param %s, but the value isn't an array of where query params, it's just %s'. It should be an array, eg array('EVT_ID'=>23,'OR'=>array('Venue.VNU_ID'=>32,'Venue.VNU_name'=>'monkey_land'))", "event_espresso"),
1874 1880
 							$param,$possibly_array_of_params));
1875
-					}else{
1881
+					} else{
1876 1882
 						$this->_extract_related_models_from_sub_params_array_keys($possibly_array_of_params, $model_query_info_carrier,$query_param_type);
1877 1883
 					}
1878
-				}elseif($query_param_type === 0 //ie WHERE
1884
+				} elseif($query_param_type === 0 //ie WHERE
1879 1885
 						&& is_array($possibly_array_of_params)
1880 1886
 						&& isset($possibly_array_of_params[2])
1881 1887
 						&& $possibly_array_of_params[2] == true){
@@ -1936,7 +1942,7 @@  discard block
 block discarded – undo
1936 1942
 		$query_object = $this->_extract_related_models_from_query($query_params);
1937 1943
 		if(array_key_exists(0,$query_params)){
1938 1944
 			$where_query_params = $query_params[0];
1939
-		}else{
1945
+		} else{
1940 1946
 			$where_query_params = array();
1941 1947
 		}
1942 1948
 		//verify where_query_params has NO numeric indexes.... that's simply not how you use it!
@@ -1947,7 +1953,7 @@  discard block
 block discarded – undo
1947 1953
 		}
1948 1954
 		if( array_key_exists( 'default_where_conditions',$query_params) && ! empty( $query_params['default_where_conditions'] )){
1949 1955
 			$use_default_where_conditions = $query_params['default_where_conditions'];
1950
-		}else{
1956
+		} else{
1951 1957
 			$use_default_where_conditions = 'all';
1952 1958
 		}
1953 1959
 		$where_query_params = array_merge($this->_get_default_where_conditions_for_models_in_query($query_object,$use_default_where_conditions,$where_query_params), $where_query_params );
@@ -1970,7 +1976,7 @@  discard block
 block discarded – undo
1970 1976
 				}
1971 1977
 				//they passed us an array for the limit. Assume it's like array(50,25), meaning offset by 50, and get 25
1972 1978
 				$query_object->set_limit_sql(" LIMIT ".$query_params['limit'][0].",".$query_params['limit'][1]);
1973
-			}elseif( ! empty ( $query_params['limit'] )){
1979
+			} elseif( ! empty ( $query_params['limit'] )){
1974 1980
 				$query_object->set_limit_sql((" LIMIT ".$query_params['limit']));
1975 1981
 			}
1976 1982
 		}
@@ -1992,11 +1998,11 @@  discard block
 block discarded – undo
1992 1998
 					$order_array[] = $this->_deduce_column_name_from_query_param($field_name_to_order_by).SP.$order;
1993 1999
 				}
1994 2000
 				$query_object->set_order_by_sql(" ORDER BY ".implode(",",$order_array));
1995
-			}elseif( ! empty ( $query_params['order_by'] )){
2001
+			} elseif( ! empty ( $query_params['order_by'] )){
1996 2002
 				$this->_extract_related_model_info_from_query_param($query_params['order_by'],$query_object,'order',$query_params['order_by']);
1997 2003
 				if(isset($query_params['order'])){
1998 2004
 					$order = $this->_extract_order($query_params['order']);
1999
-				}else{
2005
+				} else{
2000 2006
 					$order = 'DESC';
2001 2007
 				}
2002 2008
 				$query_object->set_order_by_sql(" ORDER BY ".$this->_deduce_column_name_from_query_param($query_params['order_by']).SP.$order);
@@ -2019,7 +2025,7 @@  discard block
 block discarded – undo
2019 2025
 					$group_by_array[] = $this->_deduce_column_name_from_query_param($field_name_to_group_by);
2020 2026
 				}
2021 2027
 				$query_object->set_group_by_sql(" GROUP BY ".implode(", ",$group_by_array));
2022
-			}elseif( ! empty ( $query_params['group_by'] )){
2028
+			} elseif( ! empty ( $query_params['group_by'] )){
2023 2029
 				$query_object->set_group_by_sql(" GROUP BY ".$this->_deduce_column_name_from_query_param($query_params['group_by']));
2024 2030
 			}
2025 2031
 		}
@@ -2043,8 +2049,9 @@  discard block
 block discarded – undo
2043 2049
 			}
2044 2050
 		}
2045 2051
 		$main_model_join_sql = $query_object->get_main_model_join_sql();
2046
-		if ( empty( $main_model_join_sql ) )
2047
-			$query_object->set_main_model_join_sql($this->_construct_internal_join());
2052
+		if ( empty( $main_model_join_sql ) ) {
2053
+					$query_object->set_main_model_join_sql($this->_construct_internal_join());
2054
+		}
2048 2055
 		return $query_object;
2049 2056
 	}
2050 2057
 
@@ -2060,7 +2067,7 @@  discard block
 block discarded – undo
2060 2067
 	private function _extract_order($should_be_order_string){
2061 2068
 		if(in_array($should_be_order_string, $this->_allowed_order_values)){
2062 2069
 			return $should_be_order_string;
2063
-		}else{
2070
+		} else{
2064 2071
 			throw new EE_Error(sprintf(__("While performing a query on '%s', tried to use '%s' as an order parameter. ", "event_espresso"),get_class($this),$should_be_order_string));
2065 2072
 		}
2066 2073
 	}
@@ -2086,7 +2093,7 @@  discard block
 block discarded – undo
2086 2093
 		}
2087 2094
 		if( in_array($use_default_where_conditions, array('all','this_model_only')) ){
2088 2095
 			$universal_query_params = $this->_get_default_where_conditions();
2089
-		}else{
2096
+		} else{
2090 2097
 			$universal_query_params = array();
2091 2098
 		}
2092 2099
 
@@ -2126,14 +2133,14 @@  discard block
 block discarded – undo
2126 2133
 		foreach($default_where_conditions as $key => $val){
2127 2134
 			if( isset($provided_where_conditions[$key])){
2128 2135
 				$none_overridden = false;
2129
-			}else{
2136
+			} else{
2130 2137
 				$null_friendly_where_conditions[$or_condition_key_for_defaults]['AND'][$key] = $val;
2131 2138
 			}
2132 2139
 		}
2133 2140
 		if( $none_overridden && $default_where_conditions){
2134 2141
 			if($model->has_primary_key_field()){
2135 2142
 				$null_friendly_where_conditions[$or_condition_key_for_defaults][$model_relation_path.".".$model->primary_key_name()] = array('IS NULL');
2136
-			}else{
2143
+			} else{
2137 2144
 				//@todo NO PK, use other defaults
2138 2145
 			}
2139 2146
 		}
@@ -2149,8 +2156,9 @@  discard block
 block discarded – undo
2149 2156
 	 * @return array like EEM_Base::get_all's $query_params[0] (where conditions)
2150 2157
 	 */
2151 2158
 	private function _get_default_where_conditions($model_relation_path = null){
2152
-		if ( $this->_ignore_where_strategy )
2153
-			return array();
2159
+		if ( $this->_ignore_where_strategy ) {
2160
+					return array();
2161
+		}
2154 2162
 
2155 2163
 		return $this->_default_where_conditions_strategy->get_default_where_conditions($model_relation_path);
2156 2164
 	}
@@ -2224,7 +2232,7 @@  discard block
 block discarded – undo
2224 2232
 		if(array_key_exists($query_param,$this_model_fields)){
2225 2233
 			if($allow_fields){
2226 2234
 				return;
2227
-			}else{
2235
+			} else{
2228 2236
 				throw new EE_Error(sprintf(__("Using a field name (%s) on model %s is not allowed on this query param type '%s'. Original query param was %s", "event_espresso"),
2229 2237
 						$query_param,get_class($this),$query_param_type,$original_query_param));
2230 2238
 			}
@@ -2233,7 +2241,7 @@  discard block
 block discarded – undo
2233 2241
 		elseif(in_array($query_param, $this->_logic_query_param_keys, TRUE)){
2234 2242
 			if($allow_logic_query_params){
2235 2243
 				return;
2236
-			}else{
2244
+			} else{
2237 2245
 				throw new EE_Error(
2238 2246
 					sprintf(
2239 2247
 						__( 'Logic query params ("%1$s") are being used incorrectly with the following query param ("%2$s") on model %3$s. %4$sAdditional Info:%4$s%5$s', 'event_espresso' ),
@@ -2263,12 +2271,12 @@  discard block
 block discarded – undo
2263 2271
 					//we should actually end in a field name, not a model like this!
2264 2272
 					throw new EE_Error(sprintf(__("Query param '%s' (of type %s on model %s) shouldn't end on a period (.) ", "event_espresso"),
2265 2273
 					$query_param,$query_param_type,get_class($this),$valid_related_model_name));
2266
-				}else{
2274
+				} else{
2267 2275
 					$related_model_obj = $this->get_related_model_obj($valid_related_model_name);
2268 2276
 					$related_model_obj->_extract_related_model_info_from_query_param($query_param, $passed_in_query_info, $query_param_type, $original_query_param);
2269 2277
 					return;
2270 2278
 				}
2271
-			}elseif($query_param == $valid_related_model_name){
2279
+			} elseif($query_param == $valid_related_model_name){
2272 2280
 				$this->_add_join_to_model($valid_related_model_name, $passed_in_query_info,$original_query_param);
2273 2281
 				return;
2274 2282
 			}
@@ -2328,7 +2336,7 @@  discard block
 block discarded – undo
2328 2336
 		$SQL = $this->_construct_condition_clause_recursive($where_params, ' AND ');
2329 2337
 		if($SQL){
2330 2338
 			return " WHERE ". $SQL;
2331
-		}else{
2339
+		} else{
2332 2340
 			return '';
2333 2341
 		}
2334 2342
 	}
@@ -2343,7 +2351,7 @@  discard block
 block discarded – undo
2343 2351
 		$SQL = $this->_construct_condition_clause_recursive($having_params, ' AND ');
2344 2352
 		if($SQL){
2345 2353
 			return " HAVING ". $SQL;
2346
-		}else{
2354
+		} else{
2347 2355
 			return '';
2348 2356
 		}
2349 2357
 
@@ -2366,7 +2374,7 @@  discard block
 block discarded – undo
2366 2374
 			$model_instance=call_user_func($model_name."::instance");
2367 2375
 			/* @var $model_instance EEM_Base */
2368 2376
 			return $model_instance->field_settings_for($field_name);
2369
-		}else{
2377
+		} else{
2370 2378
 			throw new EE_Error(sprintf(__('No model named %s exists, with classname %s and filepath %s','event_espresso'),$model_name,$model_class,$model_filepath));
2371 2379
 		}
2372 2380
 	}
@@ -2399,14 +2407,14 @@  discard block
 block discarded – undo
2399 2407
 						$where_clauses[] = " (". $this->_construct_condition_clause_recursive($op_and_value_or_sub_condition, ' OR ') .")";
2400 2408
 						break;
2401 2409
 				}
2402
-			}else{
2410
+			} else{
2403 2411
 				$field_obj = $this->_deduce_field_from_query_param($query_param);
2404 2412
 
2405 2413
 				//if it's not a normal field, maybe it's a custom selection?
2406 2414
 				if( ! $field_obj){
2407 2415
 					if(isset( $this->_custom_selections[$query_param][1])){
2408 2416
 						$field_obj = $this->_custom_selections[$query_param][1];
2409
-					}else{
2417
+					} else{
2410 2418
 						throw new EE_Error(sprintf(__("%s is neither a valid model field name, nor a custom selection", "event_espresso"),$query_param));
2411 2419
 					}
2412 2420
 				}
@@ -2416,7 +2424,7 @@  discard block
 block discarded – undo
2416 2424
 		}
2417 2425
 		if($where_clauses){
2418 2426
 			$SQL = implode($glue,$where_clauses);
2419
-		}else{
2427
+		} else{
2420 2428
 			$SQL = '';
2421 2429
 		}
2422 2430
 		return $SQL;
@@ -2436,11 +2444,11 @@  discard block
 block discarded – undo
2436 2444
 		if( $field ){
2437 2445
 			$table_alias_prefix = EE_Model_Parser::extract_table_alias_model_relation_chain_from_query_param( $field->get_model_name(), $query_param );
2438 2446
 			return $table_alias_prefix . $field->get_qualified_column();
2439
-		}elseif(array_key_exists($query_param,$this->_custom_selections)){
2447
+		} elseif(array_key_exists($query_param,$this->_custom_selections)){
2440 2448
 			//maybe it's custom selection item?
2441 2449
 			//if so, just use it as the "column name"
2442 2450
 			return $query_param;
2443
-		}else{
2451
+		} else{
2444 2452
 			throw new EE_Error(sprintf(__("%s is not a valid field on this model, nor a custom selection (%s)", "event_espresso"),$query_param,implode(",",$this->_custom_selections)));
2445 2453
 		}
2446 2454
 	}
@@ -2457,7 +2465,7 @@  discard block
 block discarded – undo
2457 2465
 		$pos_of_star = strpos($condition_query_param_key, '*');
2458 2466
 		if($pos_of_star === FALSE){
2459 2467
 			return $condition_query_param_key;
2460
-		}else{
2468
+		} else{
2461 2469
 			$condition_query_param_sans_star = substr($condition_query_param_key, 0, $pos_of_star);
2462 2470
 			return $condition_query_param_sans_star;
2463 2471
 		}
@@ -2483,7 +2491,7 @@  discard block
 block discarded – undo
2483 2491
 				throw new EE_Error(sprintf(__("You setup a query parameter like you were going to specify an operator, but didn't. You provided '(%s)', but the operator should be at array key index 0 (eg array('>',32))", "event_espresso"), implode(",",$php_array_like_string)));
2484 2492
 			}
2485 2493
 			$value = isset($op_and_value[1]) ? $op_and_value[1] : null;
2486
-		}else{
2494
+		} else{
2487 2495
 			$operator = '=';
2488 2496
 			$value = $op_and_value;
2489 2497
 		}
@@ -2491,7 +2499,7 @@  discard block
 block discarded – undo
2491 2499
 		//check to see if the value is actually another field
2492 2500
 		if(is_array($op_and_value) && isset($op_and_value[2]) && $op_and_value[2] == true){
2493 2501
 			return $operator.SP.$this->_deduce_column_name_from_query_param($value);
2494
-		}elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
2502
+		} elseif(in_array($operator, $this->_in_style_operators) && is_array($value)){
2495 2503
 			//in this case, the value should be an array, or at least a comma-separated list
2496 2504
 			//it will need to handle a little differently
2497 2505
 			$cleaned_value = $this->_construct_in_value($value, $field_obj);
@@ -2499,8 +2507,9 @@  discard block
 block discarded – undo
2499 2507
 			return $operator.SP.$cleaned_value;
2500 2508
 		} elseif( in_array( $operator, $this->_between_style_operators ) && is_array( $value ) ) {
2501 2509
 			//the value should be an array with count of two.
2502
-			if ( count($value) !== 2 )
2503
-				throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
2510
+			if ( count($value) !== 2 ) {
2511
+							throw new EE_Error( sprintf( __("The '%s' operator must be used with an array of values and there must be exactly TWO values in that array.", 'event_espresso'), "BETWEEN" ) );
2512
+			}
2504 2513
 			$cleaned_value = $this->_construct_between_value( $value, $field_obj );
2505 2514
 			return $operator.SP.$cleaned_value;
2506 2515
 		} elseif( in_array( $operator, $this->_null_style_operators ) ) {
@@ -2508,17 +2517,17 @@  discard block
 block discarded – undo
2508 2517
 				throw new EE_Error(sprintf(__("You attempted to give a value  (%s) while using a NULL-style operator (%s). That isn't valid", "event_espresso"),$value,$operator));
2509 2518
 			}
2510 2519
 			return $operator;
2511
-		}elseif( $operator == 'LIKE' && ! is_array($value)){
2520
+		} elseif( $operator == 'LIKE' && ! is_array($value)){
2512 2521
 			//if the operator is 'LIKE', we want to allow percent signs (%) and not
2513 2522
 			//remove other junk. So just treat it as a string.
2514 2523
 			return $operator.SP.$this->_wpdb_prepare_using_field($value, '%s');
2515
-		}elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2524
+		} elseif( ! in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2516 2525
 			return $operator.SP.$this->_wpdb_prepare_using_field($value,$field_obj);
2517
-		}elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2526
+		} elseif(in_array($operator, $this->_in_style_operators) && ! is_array($value)){
2518 2527
 			throw new EE_Error(sprintf(__("Operator '%s' must be used with an array of values, eg 'Registration.REG_ID' => array('%s',array(1,2,3))",'event_espresso'),$operator, $operator));
2519
-		}elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
2528
+		} elseif( ! in_array($operator, $this->_in_style_operators) && is_array($value)){
2520 2529
 			throw new EE_Error(sprintf(__("Operator '%s' must be used with a single value, not an array. Eg 'Registration.REG_ID => array('%s',23))",'event_espresso'),$operator,$operator));
2521
-		}else{
2530
+		} else{
2522 2531
 			throw new EE_Error(sprintf(__("It appears you've provided some totally invalid query parameters. Operator and value were:'%s', which isn't right at all", "event_espresso"),  http_build_query($op_and_value)));
2523 2532
 		}
2524 2533
 	}
@@ -2587,7 +2596,7 @@  discard block
 block discarded – undo
2587 2596
 		global $wpdb;
2588 2597
 		if($field_obj instanceof EE_Model_Field_Base){
2589 2598
 			return $wpdb->prepare($field_obj->get_wpdb_data_type(),$this->_prepare_value_for_use_in_db($value, $field_obj));
2590
-		}else{//$field_obj should really just be a data type
2599
+		} else{//$field_obj should really just be a data type
2591 2600
 			if( ! in_array($field_obj,$this->_valid_wpdb_data_types)){
2592 2601
 				throw new EE_Error(sprintf(__("%s is not a valid wpdb datatype. Valid ones are %s", "event_espresso"),$field_obj,implode(",",$this->_valid_wpdb_data_types)));
2593 2602
 			}
@@ -2616,14 +2625,14 @@  discard block
 block discarded – undo
2616 2625
 		if($number_of_parts == 1){
2617 2626
 			$field_name = $last_query_param_part;
2618 2627
 			$model_obj = $this;
2619
-		}else{// $number_of_parts >= 2
2628
+		} else{// $number_of_parts >= 2
2620 2629
 			//the last part is the column name, and there are only 2parts. therefore...
2621 2630
 			$field_name = $last_query_param_part;
2622 2631
 			$model_obj = $this->get_related_model_obj( $query_param_parts[ $number_of_parts - 2 ]);
2623 2632
 		}
2624 2633
 		try{
2625 2634
 			return $model_obj->field_settings_for($field_name);
2626
-		}catch(EE_Error $e){
2635
+		} catch(EE_Error $e){
2627 2636
 			return null;
2628 2637
 		}
2629 2638
 	}
@@ -2642,7 +2651,7 @@  discard block
 block discarded – undo
2642 2651
 		$field = isset($all_fields[$field_name]) ? $all_fields[$field_name] : FALSE;
2643 2652
 		if($field){
2644 2653
 			return $field->get_qualified_column();
2645
-		}else{
2654
+		} else{
2646 2655
 			throw new EE_Error(sprintf(__("There is no field titled %s on model %s. Either the query trying to use it is bad, or you need to add it to the list of fields on the model.",'event_espresso'),$field_name,get_class($this)));
2647 2656
 		}
2648 2657
 	}
@@ -2708,7 +2717,7 @@  discard block
 block discarded – undo
2708 2717
 					//the FROM statement, BUT the primary table isn't. So we want
2709 2718
 					//to add the inverse join sql
2710 2719
 					$SQL .= $table_obj->get_inverse_join_sql($alias_prefixed);
2711
-				}else{
2720
+				} else{
2712 2721
 					//just add a regular JOIN to this table from the primary table
2713 2722
 					$SQL .= $table_obj->get_join_sql($alias_prefixed);
2714 2723
 				}
@@ -2823,7 +2832,7 @@  discard block
 block discarded – undo
2823 2832
 		$fieldSettings = $this->field_settings(true);
2824 2833
 		if( isset($fieldSettings[$fieldName])){
2825 2834
 			return true;
2826
-		}else{
2835
+		} else{
2827 2836
 			return false;
2828 2837
 		}
2829 2838
 	}
@@ -2837,7 +2846,7 @@  discard block
 block discarded – undo
2837 2846
 		$relations = $this->relation_settings();
2838 2847
 		if(isset($relations[$relation_name])){
2839 2848
 			return true;
2840
-		}else{
2849
+		} else{
2841 2850
 			return false;
2842 2851
 		}
2843 2852
 	}
@@ -2888,7 +2897,7 @@  discard block
 block discarded – undo
2888 2897
 			try{
2889 2898
 				$this->get_primary_key_field();
2890 2899
 				$this->_has_primary_key_field = true;
2891
-			}catch(EE_Error $e){
2900
+			} catch(EE_Error $e){
2892 2901
 				$this->_has_primary_key_field = false;
2893 2902
 			}
2894 2903
 		}
@@ -2967,7 +2976,7 @@  discard block
 block discarded – undo
2967 2976
 				}
2968 2977
 			}
2969 2978
 			return $this->_cached_fields;
2970
-		}else{
2979
+		} else{
2971 2980
 			if( $this->_cached_fields_non_db_only === NULL ){
2972 2981
 				$this->_cached_fields_non_db_only = array();
2973 2982
 				foreach($this->_fields as $fields_corresponding_to_table){
@@ -3099,7 +3108,7 @@  discard block
 block discarded – undo
3099 3108
 			if(empty( $this_model_fields_n_values[$this->primary_key_name()] )){
3100 3109
 				return NULL;
3101 3110
 			}
3102
-		}else if($this->unique_indexes()){
3111
+		} else if($this->unique_indexes()){
3103 3112
 			$first_column = reset($this_model_fields_n_values);
3104 3113
 			if(empty($first_column)){
3105 3114
 				return NULL;
@@ -3114,7 +3123,7 @@  discard block
 block discarded – undo
3114 3123
 				// add this new object to the entity map
3115 3124
 				$classInstance = $this->add_to_entity_map( $classInstance );
3116 3125
 			}
3117
-		}else{
3126
+		} else{
3118 3127
 			$classInstance = EE_Registry::instance()->load_class( $className, array( $this_model_fields_n_values, $this->_timezone ), TRUE, FALSE );
3119 3128
 		}
3120 3129
 
@@ -3199,11 +3208,12 @@  discard block
 block discarded – undo
3199 3208
 						$this_model_fields_n_values[$field_name] = $field_obj->get_default_value();
3200 3209
 					}
3201 3210
 				}
3202
-			}else{
3211
+			} else{
3203 3212
 				//the table's rows existed. Use their values
3204 3213
 				foreach( $this->_get_fields_for_table( $table_alias ) as $field_name => $field_obj ) {
3205
-					if( ! $field_obj->is_db_only_field() )
3206
-					$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3214
+					if( ! $field_obj->is_db_only_field() ) {
3215
+										$this_model_fields_n_values[$field_name] = $this->_get_column_value_with_table_alias_or_not($cols_n_values, $field_obj->get_qualified_column(), $field_obj->get_table_column() );
3216
+					}
3207 3217
 				}
3208 3218
 			}
3209 3219
 		}
@@ -3217,9 +3227,9 @@  discard block
 block discarded – undo
3217 3227
 		if( isset( $cols_n_values[ $qualified_column ] ) ){
3218 3228
 			$value = $cols_n_values[ $qualified_column ];
3219 3229
 
3220
-		}elseif( isset( $cols_n_values[ $regular_column ] ) ){
3230
+		} elseif( isset( $cols_n_values[ $regular_column ] ) ){
3221 3231
 			$value = $cols_n_values[ $regular_column ];
3222
-		}else{
3232
+		} else{
3223 3233
 			$value = NULL;
3224 3234
 		}
3225 3235
 
@@ -3252,7 +3262,7 @@  discard block
 block discarded – undo
3252 3262
 				}
3253 3263
 			}
3254 3264
 			return $obj_in_map;
3255
-		}else{
3265
+		} else{
3256 3266
 			return $this->get_one_by_ID( $id );
3257 3267
 		}
3258 3268
 	}
@@ -3287,7 +3297,7 @@  discard block
 block discarded – undo
3287 3297
 				}
3288 3298
 			}
3289 3299
 			return $obj_in_map;
3290
-		}else{
3300
+		} else{
3291 3301
 			$this->add_to_entity_map( $replacing_model_obj );
3292 3302
 			return $replacing_model_obj;
3293 3303
 		}
@@ -3317,7 +3327,7 @@  discard block
 block discarded – undo
3317 3327
 	public function item_name($quantity = 1){
3318 3328
 		if($quantity == 1){
3319 3329
 			return $this->singular_item;
3320
-		}else{
3330
+		} else{
3321 3331
 			return $this->plural_item;
3322 3332
 		}
3323 3333
 	}
@@ -3379,14 +3389,14 @@  discard block
 block discarded – undo
3379 3389
 		$primary_key_field = $this->get_primary_key_field();
3380 3390
 		if( $base_class_obj_or_id instanceof $className ){
3381 3391
 			$model_object = $base_class_obj_or_id;
3382
-		}elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
3392
+		} elseif( $primary_key_field instanceof EE_Primary_Key_Int_Field && (
3383 3393
 				is_int( $base_class_obj_or_id ) ||
3384 3394
 				is_string( $base_class_obj_or_id ) )){//assume it's an ID. either a proper integer or a string representing an integer (eg "101" instead of 101)
3385 3395
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3386
-		}elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
3396
+		} elseif( $primary_key_field instanceof EE_Primary_Key_String_Field && is_string($base_class_obj_or_id) ){
3387 3397
 			//assume its a string representation of the object
3388 3398
 			$model_object = $this->get_one_by_ID($base_class_obj_or_id);
3389
-		}else{
3399
+		} else{
3390 3400
 			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
3391 3401
 		}
3392 3402
 		if( $model_object->ID() == NULL && $ensure_is_in_db){
@@ -3410,13 +3420,13 @@  discard block
 block discarded – undo
3410 3420
 		if( $base_class_obj_or_id instanceof $className ){
3411 3421
 			/** @var $base_class_obj_or_id EE_Base_Class */
3412 3422
 			$id = $base_class_obj_or_id->ID();
3413
-		}elseif(is_int($base_class_obj_or_id)){
3423
+		} elseif(is_int($base_class_obj_or_id)){
3414 3424
 			//assume it's an ID
3415 3425
 			$id = $base_class_obj_or_id;
3416
-		}elseif(is_string($base_class_obj_or_id)){
3426
+		} elseif(is_string($base_class_obj_or_id)){
3417 3427
 			//assume its a string representation of the object
3418 3428
 			$id = $base_class_obj_or_id;
3419
-		}else{
3429
+		} else{
3420 3430
 			throw new EE_Error(sprintf(__("'%s' is neither an object of type %s, nor an ID! Its full value is '%s'",'event_espresso'),$base_class_obj_or_id,$this->_get_class_name(),print_r($base_class_obj_or_id,true)));
3421 3431
 		}
3422 3432
 		return $id;
@@ -3547,9 +3557,9 @@  discard block
 block discarded – undo
3547 3557
 
3548 3558
 		if($model_object_or_attributes_array instanceof EE_Base_Class){
3549 3559
 			$attributes_array = $model_object_or_attributes_array->model_field_array();
3550
-		}elseif(is_array($model_object_or_attributes_array)){
3560
+		} elseif(is_array($model_object_or_attributes_array)){
3551 3561
 			$attributes_array = $model_object_or_attributes_array;
3552
-		}else{
3562
+		} else{
3553 3563
 			throw new EE_Error(sprintf(__("get_all_copies should be provided with either a model object or an array of field-value-pairs, but was given %s", "event_espresso"),$model_object_or_attributes_array));
3554 3564
 		}
3555 3565
 		//even copies obviously won't have the same ID, so remove the primary key
@@ -3559,7 +3569,7 @@  discard block
 block discarded – undo
3559 3569
 		}
3560 3570
 		if(isset($query_params[0])){
3561 3571
 			$query_params[0] = array_merge($attributes_array,$query_params);
3562
-		}else{
3572
+		} else{
3563 3573
 			$query_params[0] = $attributes_array;
3564 3574
 		}
3565 3575
 		return $this->get_all($query_params);
@@ -3582,7 +3592,7 @@  discard block
 block discarded – undo
3582 3592
 		$copies = $this->get_all_copies($model_object_or_attributes_array,$query_params);
3583 3593
 		if(is_array($copies)){
3584 3594
 			return array_shift($copies);
3585
-		}else{
3595
+		} else{
3586 3596
 			return null;
3587 3597
 		}
3588 3598
 	}
@@ -3614,7 +3624,7 @@  discard block
 block discarded – undo
3614 3624
 		$sql_operator = isset($this->_valid_operators[$operator_supplied]) ? $this->_valid_operators[$operator_supplied] : null;
3615 3625
 		if($sql_operator){
3616 3626
 			return $sql_operator;
3617
-		}else{
3627
+		} else{
3618 3628
 			throw new EE_Error(sprintf(__("The operator '%s' is not in the list of valid operators: %s", "event_espresso"),$operator_supplied,implode(",",array_keys($this->_valid_operators))));
3619 3629
 		}
3620 3630
 	}
Please login to merge, or discard this patch.
core/db_models/EEM_Currency_Payment_Method.model.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -25,29 +25,29 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEM_Currency_Payment_Method extends EEM_Base{
28
+class EEM_Currency_Payment_Method extends EEM_Base {
29 29
 	// private instance of the Attendee object
30 30
 	protected static $_instance = NULL;
31 31
 
32 32
 
33
-	protected function __construct( $timezone = NULL ) {
34
-		$this->singular_item = __('Currency Usable by Payment Method','event_espresso');
35
-		$this->plural_item = __('Currencies Usable by Payment Methods','event_espresso');
33
+	protected function __construct($timezone = NULL) {
34
+		$this->singular_item = __('Currency Usable by Payment Method', 'event_espresso');
35
+		$this->plural_item = __('Currencies Usable by Payment Methods', 'event_espresso');
36 36
 		$this->_tables = array(
37
-			'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method','CPM_ID')
37
+			'Currency_Payment_Method'=>new EE_Primary_Table('esp_currency_payment_method', 'CPM_ID')
38 38
 		);
39 39
 		$this->_fields = array(
40 40
 			'Currency_Payment_Method'=>array(
41
-				'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID','event_espresso')),
42
-				'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code','event_espresso'), false, 0, 'Currency'),
43
-				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID','event_espresso'), false, 0, 'Payment_Method')
41
+				'CPM_ID'=>new EE_Primary_Key_Int_Field('CPM_ID', __('Currency to Payment Method LInk ID', 'event_espresso')),
42
+				'CUR_code'=>new EE_Foreign_Key_String_Field('CUR_code', __('Currency Code', 'event_espresso'), false, 0, 'Currency'),
43
+				'PMD_ID'=>new EE_Foreign_Key_Int_Field('PMD_ID', __('Paymetn Method ID', 'event_espresso'), false, 0, 'Payment_Method')
44 44
 			)
45 45
 		);
46 46
 		$this->_model_relations = array(
47 47
 			'Currency'=>new EE_Belongs_To_Relation(),
48 48
 			'Payment_Method'=>new EE_Belongs_To_Relation()
49 49
 		);
50
-		parent::__construct( $timezone );
50
+		parent::__construct($timezone);
51 51
 	}
52 52
 }
53 53
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if (!defined('EVENT_ESPRESSO_VERSION')) {
4 4
 	exit('No direct script access allowed');
5
+}
5 6
 
6 7
 /**
7 8
  * Event Espresso
Please login to merge, or discard this patch.
core/db_models/EEM_Datetime_Ticket.model.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
25
-require_once ( EE_CLASSES . 'EE_Datetime_Ticket.class.php' );
24
+require_once (EE_MODELS.'EEM_Base.model.php');
25
+require_once (EE_CLASSES.'EE_Datetime_Ticket.class.php');
26 26
 
27 27
 class EEM_Datetime_Ticket extends EEM_Base {
28 28
 
@@ -37,24 +37,24 @@  discard block
 block discarded – undo
37 37
 	 *		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
38 38
 	 *		@return void
39 39
 	 */
40
-	protected function __construct( $timezone ) {
41
-		$this->singular_item = __('Datetime Ticket','event_espresso');
42
-		$this->plural_item = __('Datetime Tickets','event_espresso');
40
+	protected function __construct($timezone) {
41
+		$this->singular_item = __('Datetime Ticket', 'event_espresso');
42
+		$this->plural_item = __('Datetime Tickets', 'event_espresso');
43 43
 
44 44
 		$this->_tables = array(
45 45
 			'Datetime_Ticket'=> new EE_Primary_Table('esp_datetime_ticket', 'DTK_ID')
46 46
 		);
47 47
 		$this->_fields = array(
48 48
 			'Datetime_Ticket'=>array(
49
-				'DTK_ID'=>new EE_Primary_Key_Int_Field('DTK_ID', __('Datetime Ticket ID','event_espresso')),
50
-				'DTT_ID'=>new EE_Foreign_Key_Int_Field('DTT_ID', __('The ID to the Datetime','event_espresso'), false, 0, 'Datetime' ),
51
-				'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('The ID to the Ticket','event_espresso'), false, 0, 'Ticket' )
49
+				'DTK_ID'=>new EE_Primary_Key_Int_Field('DTK_ID', __('Datetime Ticket ID', 'event_espresso')),
50
+				'DTT_ID'=>new EE_Foreign_Key_Int_Field('DTT_ID', __('The ID to the Datetime', 'event_espresso'), false, 0, 'Datetime'),
51
+				'TKT_ID'=>new EE_Foreign_Key_Int_Field('TKT_ID', __('The ID to the Ticket', 'event_espresso'), false, 0, 'Ticket')
52 52
 			));
53 53
 		$this->_model_relations = array(
54 54
 			'Ticket'=>new EE_Belongs_To_Relation(),
55 55
 			'Datetime'=>new EE_Belongs_To_Relation()
56 56
 		);
57 57
 
58
-		parent::__construct( $timezone );
58
+		parent::__construct($timezone);
59 59
 	}
60 60
 } //end EEM_Datetime_Ticket class
61 61
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/db_models/EEM_Event_Question_Group.model.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -5,31 +5,31 @@
 block discarded – undo
5 5
  * You'll need to use each's EE_Has_Many_Relation relation to this model. Eg, when querying for question groups which apply to primary attendees,
6 6
  * you'd do a query like EEM_Question_Group::instance()->get_all(array(array('Event_Question_Group.EQG_primary'=>1)));
7 7
  */
8
-require_once( EE_CLASSES . 'EE_Event_Question_Group.class.php');
8
+require_once(EE_CLASSES.'EE_Event_Question_Group.class.php');
9 9
 
10
-class EEM_Event_Question_Group extends EEM_Base{
10
+class EEM_Event_Question_Group extends EEM_Base {
11 11
 	// private instance of the Attendee object
12 12
 	protected static $_instance = NULL;
13 13
 
14
-	protected function __construct( $timezone = NULL ) {
15
-		$this->singular_item = __('Event to Question Group Link','event_espresso');
16
-		$this->plural_item = __('Event to Question Group Links','event_espresso');
14
+	protected function __construct($timezone = NULL) {
15
+		$this->singular_item = __('Event to Question Group Link', 'event_espresso');
16
+		$this->plural_item = __('Event to Question Group Links', 'event_espresso');
17 17
 		$this->_tables = array(
18
-			'Event_Question_Group'=>new EE_Primary_Table('esp_event_question_group','EQG_ID')
18
+			'Event_Question_Group'=>new EE_Primary_Table('esp_event_question_group', 'EQG_ID')
19 19
 		);
20 20
 		$this->_fields = array(
21 21
 			'Event_Question_Group'=>array(
22
-				'EQG_ID'=>new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID','event_espresso')),
23
-				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'),
24
-				'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id','event_espresso'), false, 0, 'Question_Group'),
25
-				'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees','event_espresso'), false, false)
22
+				'EQG_ID'=>new EE_Primary_Key_Int_Field('EQG_ID', __('Event to Question Group Link ID', 'event_espresso')),
23
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
24
+				'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group Id', 'event_espresso'), false, 0, 'Question_Group'),
25
+				'EQG_primary'=>new EE_Boolean_Field('EQG_primary', __('Flag indicating question is only for primary attendees', 'event_espresso'), false, false)
26 26
 			)
27 27
 		);
28 28
 		$this->_model_relations = array(
29 29
 			'Event'=>new EE_Belongs_To_Relation(),
30 30
 			'Question_Group'=>new EE_Belongs_To_Relation()
31 31
 		);
32
-		parent::__construct( $timezone );
32
+		parent::__construct($timezone);
33 33
 	}
34 34
 
35 35
 
Please login to merge, or discard this patch.
core/db_models/EEM_Event_Venue.model.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,22 +5,22 @@  discard block
 block discarded – undo
5 5
  * You'll need to use each's EE_Has_Many_Relation relation to this model. Eg, when querying for question groups which apply to primary attendees,
6 6
  * you'd do a query like EEM_Question_Group::instance()->get_all(array(array('Event_Question_Group.EQG_primary'=>1)));
7 7
  */
8
-class EEM_Event_Venue extends EEM_Base{
8
+class EEM_Event_Venue extends EEM_Base {
9 9
 	// private instance of the Attendee object
10 10
 	protected static $_instance = NULL;
11 11
 
12
-	protected function __construct( $timezone = NULL ) {
13
-		$this->singular_item = __('Event to Question Group Link','event_espresso');
14
-		$this->plural_item = __('Event to Question Group Links','event_espresso');
12
+	protected function __construct($timezone = NULL) {
13
+		$this->singular_item = __('Event to Question Group Link', 'event_espresso');
14
+		$this->plural_item = __('Event to Question Group Links', 'event_espresso');
15 15
 		$this->_tables = array(
16
-			'Event_Venue'=>new EE_Primary_Table('esp_event_venue','EVV_ID')
16
+			'Event_Venue'=>new EE_Primary_Table('esp_event_venue', 'EVV_ID')
17 17
 		);
18 18
 		$this->_fields = array(
19 19
 			'Event_Venue'=>array(
20
-				'EVV_ID'=>new EE_Primary_Key_Int_Field('EVV_ID', __('Event to Venue Link ID','event_espresso')),
21
-				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID','event_espresso'), false, 0, 'Event'),
22
-				'VNU_ID'=>new EE_Foreign_Key_Int_Field('VNU_ID', __('Venue ID','event_espresso'), false, 0, 'Venue'),
23
-				'EVV_primary'=>new EE_Boolean_Field('EVV_primary', __("Flag indicating venue is primary one for event", "event_espresso"), false,true)
20
+				'EVV_ID'=>new EE_Primary_Key_Int_Field('EVV_ID', __('Event to Venue Link ID', 'event_espresso')),
21
+				'EVT_ID'=>new EE_Foreign_Key_Int_Field('EVT_ID', __('Event ID', 'event_espresso'), false, 0, 'Event'),
22
+				'VNU_ID'=>new EE_Foreign_Key_Int_Field('VNU_ID', __('Venue ID', 'event_espresso'), false, 0, 'Venue'),
23
+				'EVV_primary'=>new EE_Boolean_Field('EVV_primary', __("Flag indicating venue is primary one for event", "event_espresso"), false, true)
24 24
 
25 25
 			)
26 26
 		);
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 			'Event'=>new EE_Belongs_To_Relation(),
29 29
 			'Venue'=>new EE_Belongs_To_Relation()
30 30
 		);
31
-		parent::__construct( $timezone );
31
+		parent::__construct($timezone);
32 32
 	}
33 33
 
34 34
 
Please login to merge, or discard this patch.
core/db_models/EEM_Price.model.php 2 patches
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once ( EE_CLASSES . 'EE_Price.class.php' );
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once (EE_CLASSES.'EE_Price.class.php');
26 26
 
27 27
 
28 28
 class EEM_Price extends EEM_Soft_Delete_Base {
@@ -39,18 +39,18 @@  discard block
 block discarded – undo
39 39
 	 * 		@param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved).  Note this just sends the timezone info to the date time model field objects.  Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option)
40 40
 	 * 		@return void
41 41
 	 */
42
-	protected function __construct( $timezone ) {
43
-		require_once( EE_MODELS . 'EEM_Price_Type.model.php');
44
-		$this->singular_item = __('Price','event_espresso');
45
-		$this->plural_item = __('Prices','event_espresso');
42
+	protected function __construct($timezone) {
43
+		require_once(EE_MODELS.'EEM_Price_Type.model.php');
44
+		$this->singular_item = __('Price', 'event_espresso');
45
+		$this->plural_item = __('Prices', 'event_espresso');
46 46
 
47 47
 		$this->_tables = array(
48
-			'Price'=>new EE_Primary_Table('esp_price','PRC_ID')
48
+			'Price'=>new EE_Primary_Table('esp_price', 'PRC_ID')
49 49
 		);
50 50
 		$this->_fields = array(
51 51
 			'Price'=> array(
52 52
 				'PRC_ID'=>new EE_Primary_Key_Int_Field('PRC_ID', 'Price ID'),
53
-				'PRT_ID'=>new EE_Foreign_Key_Int_Field('PRT_ID', 'Price type Id', false,  NULL, 'Price_Type'),
53
+				'PRT_ID'=>new EE_Foreign_Key_Int_Field('PRT_ID', 'Price type Id', false, NULL, 'Price_Type'),
54 54
 				'PRC_amount'=>new EE_Money_Field('PRC_amount', 'Price Amount', false, 0),
55 55
 				'PRC_name'=>new EE_Plain_Text_Field('PRC_name', 'Name of Price', false, ''),
56 56
 				'PRC_desc'=>new EE_Post_Content_Field('PRC_desc', 'Price Description', false, ''),
@@ -58,8 +58,8 @@  discard block
 block discarded – undo
58 58
 				'PRC_overrides'=>new EE_Integer_Field('PRC_overrides', 'Price ID for a global Price that will be overridden by this Price  ( for replacing default prices )', true, 0),
59 59
 				'PRC_order'=>new EE_Integer_Field('PRC_order', 'Order of Application of Price (lower numbers apply first?)', false, 1),
60 60
 				'PRC_deleted'=>new EE_Trashed_Flag_Field('PRC_deleted', 'Flag Indicating if this has been deleted or not', false, false),
61
-				'PRC_parent' => new EE_Integer_Field('PRC_parent', __('Indicates what PRC_ID is the parent of this PRC_ID'), true, 0 ),
62
-				'PRC_wp_user' => new EE_WP_User_Field('PRC_wp_user', __('Price Creator ID', 'event_espresso'), FALSE ),
61
+				'PRC_parent' => new EE_Integer_Field('PRC_parent', __('Indicates what PRC_ID is the parent of this PRC_ID'), true, 0),
62
+				'PRC_wp_user' => new EE_WP_User_Field('PRC_wp_user', __('Price Creator ID', 'event_espresso'), FALSE),
63 63
 			)
64 64
 		);
65 65
 		$this->_model_relations = array(
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
 			'Price_Type'=>new EE_Belongs_To_Relation(),
68 68
 			'WP_User' => new EE_Belongs_To_Relation(),
69 69
 		);
70
-		parent::__construct( $timezone );
70
+		parent::__construct($timezone);
71 71
 
72
-		require_once ( EE_CLASSES . 'EE_Price.class.php' );
72
+		require_once (EE_CLASSES.'EE_Price.class.php');
73 73
 
74 74
 	}
75 75
 
@@ -109,11 +109,11 @@  discard block
 block discarded – undo
109 109
 	 * 		@return 		array				on success
110 110
 	 * 		@return 		boolean			false on fail
111 111
 	 */
112
-	public function get_all_event_prices( $EVT_ID ) {
112
+	public function get_all_event_prices($EVT_ID) {
113 113
 		return $this->get_all(array(
114 114
 			array(
115 115
 				'EVT_ID'=>$EVT_ID,
116
-				'Price_Type.PBT_ID'=>array('!=',  EEM_Price_Type::base_type_tax)
116
+				'Price_Type.PBT_ID'=>array('!=', EEM_Price_Type::base_type_tax)
117 117
 			),
118 118
 			'order_by'=>$this->_order_by_array_for_get_all_method()
119 119
 		));
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
 	 * 		@return 		array				on success
129 129
 	 * 		@return 		boolean			false on fail
130 130
 	 */
131
-	public function get_all_default_prices( $count = FALSE ) {
131
+	public function get_all_default_prices($count = FALSE) {
132 132
 		$_where = array(
133
-			'Price_Type.PBT_ID'=>array('!=',4),
133
+			'Price_Type.PBT_ID'=>array('!=', 4),
134 134
 			'PRC_deleted' => 0,
135 135
 			'PRC_is_default' => 1
136 136
 		);
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
 	public function get_all_prices_that_are_taxes() {
162 162
 		$taxes = array();
163 163
 		$all_taxes = $this->get_all(array(
164
-			array( 'Price_Type.PBT_ID'=>  EEM_Price_Type::base_type_tax ),
165
-			'order_by' => array( 'Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC' )
164
+			array('Price_Type.PBT_ID'=>  EEM_Price_Type::base_type_tax),
165
+			'order_by' => array('Price_Type.PRT_order' => 'ASC', 'PRC_order' => 'ASC')
166 166
 		));
167 167
 //		$all_taxes = $this->_select_all_prices_where(
168 168
 //				array( 'prt.PBT_ID' => 4, 'prc.PRC_deleted' => FALSE )
169 169
 //		);
170
-		foreach ( $all_taxes as $tax ) {
171
-			$taxes[ $tax->order() ][ $tax->ID() ] = $tax;
170
+		foreach ($all_taxes as $tax) {
171
+			$taxes[$tax->order()][$tax->ID()] = $tax;
172 172
 		}
173 173
 		return $taxes;
174 174
 	}
@@ -184,18 +184,18 @@  discard block
 block discarded – undo
184 184
 	 * 		@param int     $TKT          the id of the event.  If not included then we assume that this is a new ticket.
185 185
 	 * 		@return 		boolean			false on fail
186 186
 	 */
187
-	public function get_all_ticket_prices_for_admin( $TKT_ID = FALSE ) {
187
+	public function get_all_ticket_prices_for_admin($TKT_ID = FALSE) {
188 188
 		$ticket_prices = array();
189
-		if ( empty($TKT_ID) ) {
189
+		if (empty($TKT_ID)) {
190 190
 
191 191
 			//if there is no tkt, get prices with no tkt ID, are global, are not a tax, and are active
192 192
 			//return that list
193 193
 			$ticket_prices = $this->get_all_default_prices();
194 194
 
195
-			if ( $global_prices ) {
195
+			if ($global_prices) {
196 196
 				$array_of_price_objects = array();
197 197
 				foreach ($global_prices as $price) {
198
-						$array_of_price_objects[ $price->type() ][] = $price;
198
+						$array_of_price_objects[$price->type()][] = $price;
199 199
 				}
200 200
 				return $array_of_price_objects;
201 201
 			} else {
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 			));
214 214
 		}
215 215
 
216
-		if ( !empty( $ticket_prices ) ) {
217
-			foreach ( $ticket_prices as $price ) {
218
-				$array_of_price_objects[ $price->type() ][] = $price;
216
+		if ( ! empty($ticket_prices)) {
217
+			foreach ($ticket_prices as $price) {
218
+				$array_of_price_objects[$price->type()][] = $price;
219 219
 			}
220 220
 			return $array_of_price_objects;
221 221
 
@@ -234,10 +234,10 @@  discard block
 block discarded – undo
234 234
 	 * 		@access		private
235 235
 	 * 		@return 		boolean			false on fail
236 236
 	 */
237
-	private function _sort_event_prices_by_type( $price_a, $price_b ) {
237
+	private function _sort_event_prices_by_type($price_a, $price_b) {
238 238
 		$PRT = EEM_Price_Type::instance();
239
-		if ( $price_a->type_obj()->order() == $price_b->type_obj()->order() ) {
240
-			return $this->_sort_event_prices_by_order( $price_a, $price_b );
239
+		if ($price_a->type_obj()->order() == $price_b->type_obj()->order()) {
240
+			return $this->_sort_event_prices_by_order($price_a, $price_b);
241 241
 		}
242 242
 		return $price_a->type_obj()->order() < $price_b->type_obj()->order() ? -1 : 1;
243 243
 	}
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 	 * 		@return 		boolean			false on fail
254 254
 	 */
255 255
 	private function _sort_event_prices_by_order($price_a, $price_b) {
256
-		if ( $price_a->order() == $price_b->order() ) {
257
-			return $this->_sort_event_prices_by_start_date( $price_a, $price_b );
256
+		if ($price_a->order() == $price_b->order()) {
257
+			return $this->_sort_event_prices_by_start_date($price_a, $price_b);
258 258
 		}
259 259
 		return $price_a->order() < $price_b->order() ? -1 : 1;
260 260
 	}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 * Of course you don't have to use it, but this is the order we usually want to sort prices by
286 286
 	 * @return array which can be used like so: $this->get_all(array(array(...where stuff...),'order_by'=>$this->_order_by_array_for_get_all_method()));
287 287
 	 */
288
-	public function _order_by_array_for_get_all_method(){
288
+	public function _order_by_array_for_get_all_method() {
289 289
 		return array(
290 290
 				'PRC_order'=>'ASC',
291 291
 				'Price_Type.PRT_order'=>'ASC',
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/db_models/EEM_Question.model.php 2 patches
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once( EE_CLASSES . 'EE_Question.class.php');
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once(EE_CLASSES.'EE_Question.class.php');
26 26
 
27 27
 class EEM_Question extends EEM_Soft_Delete_Base {
28 28
 
@@ -67,42 +67,42 @@  discard block
 block discarded – undo
67 67
 	 * but they can be extended
68 68
 	 * @return string[]
69 69
 	 */
70
-	public function allowed_question_types(){
70
+	public function allowed_question_types() {
71 71
 		return $this->_allowed_question_types;
72 72
 	}
73
-	protected function __construct( $timezone = NULL ) {
74
-		$this->singular_item = __('Question','event_espresso');
75
-		$this->plural_item = __('Questions','event_espresso');
76
-		$this->_allowed_question_types=apply_filters(
73
+	protected function __construct($timezone = NULL) {
74
+		$this->singular_item = __('Question', 'event_espresso');
75
+		$this->plural_item = __('Questions', 'event_espresso');
76
+		$this->_allowed_question_types = apply_filters(
77 77
 			'FHEE__EEM_Question__construct__allowed_question_types',
78 78
 			array(
79
-				EEM_Question::QST_type_text =>__('Text','event_espresso'),
80
-				EEM_Question::QST_type_textarea =>__('Textarea','event_espresso'),
81
-				EEM_Question::QST_type_checkbox =>__('Checkboxes','event_espresso'),
82
-				EEM_Question::QST_type_radio =>__('Radio Buttons','event_espresso'),
83
-				EEM_Question::QST_type_dropdown =>__('Dropdown','event_espresso'),
84
-				EEM_Question::QST_type_state =>__('State/Province Dropdown','event_espresso'),
85
-				EEM_Question::QST_type_country =>__('Country Dropdown','event_espresso'),
86
-				EEM_Question::QST_type_date =>__('Date Picker','event_espresso')
79
+				EEM_Question::QST_type_text =>__('Text', 'event_espresso'),
80
+				EEM_Question::QST_type_textarea =>__('Textarea', 'event_espresso'),
81
+				EEM_Question::QST_type_checkbox =>__('Checkboxes', 'event_espresso'),
82
+				EEM_Question::QST_type_radio =>__('Radio Buttons', 'event_espresso'),
83
+				EEM_Question::QST_type_dropdown =>__('Dropdown', 'event_espresso'),
84
+				EEM_Question::QST_type_state =>__('State/Province Dropdown', 'event_espresso'),
85
+				EEM_Question::QST_type_country =>__('Country Dropdown', 'event_espresso'),
86
+				EEM_Question::QST_type_date =>__('Date Picker', 'event_espresso')
87 87
 			)
88 88
 		);
89 89
 
90 90
 		$this->_tables = array(
91
-			'Question'=>new EE_Primary_Table('esp_question','QST_ID')
91
+			'Question'=>new EE_Primary_Table('esp_question', 'QST_ID')
92 92
 		);
93 93
 		$this->_fields = array(
94 94
 			'Question'=>array(
95
-				'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID','event_espresso')),
96
-				'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text','event_espresso'), true, ''),
97
-				'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)','event_espresso'), true, ''),
98
-				'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question','event_espresso'), TRUE, NULL ),
99
-				'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type','event_espresso'),false, 'TEXT',$this->_allowed_question_types),
100
-				'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?','event_espresso'), false, false),
101
-				'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided','event_espresso'), true, ''),
102
-				'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order','event_espresso'), false, 0),
103
-				'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?','event_espresso'), false, false),
104
-				'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID','event_espresso'), false ),
105
-				'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted','event_espresso'), false, false)
95
+				'QST_ID'=>new EE_Primary_Key_Int_Field('QST_ID', __('Question ID', 'event_espresso')),
96
+				'QST_display_text'=>new EE_Full_HTML_Field('QST_display_text', __('Question Text', 'event_espresso'), true, ''),
97
+				'QST_admin_label'=>new EE_Plain_Text_Field('QST_admin_label', __('Question Label (admin-only)', 'event_espresso'), true, ''),
98
+				'QST_system'=>new EE_Plain_Text_Field('QST_system', __('Internal string ID for question', 'event_espresso'), TRUE, NULL),
99
+				'QST_type'=>new EE_Enum_Text_Field('QST_type', __('Question Type', 'event_espresso'), false, 'TEXT', $this->_allowed_question_types),
100
+				'QST_required'=>new EE_Boolean_Field('QST_required', __('Required Question?', 'event_espresso'), false, false),
101
+				'QST_required_text'=>new EE_Simple_HTML_Field('QST_required_text', __('Text to Display if Not Provided', 'event_espresso'), true, ''),
102
+				'QST_order'=>new EE_Integer_Field('QST_order', __('Question Order', 'event_espresso'), false, 0),
103
+				'QST_admin_only'=>new EE_Boolean_Field('QST_admin_only', __('Admin-Only Question?', 'event_espresso'), false, false),
104
+				'QST_wp_user'=>new EE_WP_User_Field('QST_wp_user', __('Question Creator ID', 'event_espresso'), false),
105
+				'QST_deleted'=>new EE_Trashed_Flag_Field('QST_deleted', __('Flag Indicating question was deleted', 'event_espresso'), false, false)
106 106
 			)
107 107
 		);
108 108
 		$this->_model_relations = array(
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
 			'Question_Group_Question'=>new EE_Has_Many_Relation()
115 115
 		);
116 116
 
117
-		parent::__construct( $timezone );
117
+		parent::__construct($timezone);
118 118
 	}
119 119
 
120 120
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * which system question QST_ID corresponds to the QST_system 'city', use EEM_Question::instance()->get_Question_ID_from_system_string('city');
125 125
 	 * @return int of QST_ID for the question that corresponds to that QST_system
126 126
 	 */
127
-	public function get_Question_ID_from_system_string($QST_system){
127
+	public function get_Question_ID_from_system_string($QST_system) {
128 128
 		 $conversion_array = array(
129 129
 			'fname'=> EEM_Attendee::fname_question_id,
130 130
 			'lname'=> EEM_Attendee::lname_question_id,
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 			'phone'=> EEM_Attendee::phone_question_id
139 139
 		);
140 140
 
141
-		return isset( $conversion_array[ $QST_system ] ) ? $conversion_array[ $QST_system ] : NULL;
141
+		return isset($conversion_array[$QST_system]) ? $conversion_array[$QST_system] : NULL;
142 142
 
143 143
 	}
144 144
 
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
 	 */
151 151
 	public function get_latest_question_order() {
152 152
 		$columns_to_select = array(
153
-			'max_order' => array("MAX(QST_order)","%d")
153
+			'max_order' => array("MAX(QST_order)", "%d")
154 154
 			);
155
-		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select );
155
+		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
156 156
 		return $max[0]['max_order'];
157 157
 	}
158 158
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Group.model.php 2 patches
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  *
22 22
  * ------------------------------------------------------------------------
23 23
  */
24
-require_once ( EE_MODELS . 'EEM_Soft_Delete_Base.model.php' );
25
-require_once( EE_CLASSES . 'EE_Question_Group.class.php');
24
+require_once (EE_MODELS.'EEM_Soft_Delete_Base.model.php');
25
+require_once(EE_CLASSES.'EE_Question_Group.class.php');
26 26
 class EEM_Question_Group extends EEM_Soft_Delete_Base {
27 27
 	const system_personal = 1;
28 28
 	const system_address = 2;
@@ -30,25 +30,25 @@  discard block
 block discarded – undo
30 30
 	protected static $_instance = NULL;
31 31
 
32 32
 
33
-	protected function __construct( $timezone = NULL ) {
34
-		$this->singular_item = __('Question Group','event_espresso');
35
-		$this->plural_item = __('Question Groups','event_espresso');
33
+	protected function __construct($timezone = NULL) {
34
+		$this->singular_item = __('Question Group', 'event_espresso');
35
+		$this->plural_item = __('Question Groups', 'event_espresso');
36 36
 
37 37
 		$this->_tables = array(
38
-			'Question_Group'=>new EE_Primary_Table('esp_question_group','QSG_ID')
38
+			'Question_Group'=>new EE_Primary_Table('esp_question_group', 'QSG_ID')
39 39
 		);
40 40
 		$this->_fields = array(
41 41
 			'Question_Group'=>array(
42
-				'QSG_ID'=>new EE_Primary_Key_Int_Field('QSG_ID', __('Question Group ID','event_espresso')),
43
-				'QSG_name'=>new EE_Plain_Text_Field('QSG_name', __('Question Group Name','event_espresso'), false, ''),
44
-				'QSG_identifier'=>new EE_Plain_Text_Field('QSG_identifier', __('Text ID for question Group','event_espresso'), false, ''),
45
-				'QSG_desc'=>new EE_Full_HTML_Field('QSG_desc', __('Description of Question Group','event_espresso'), true, ''),
46
-				'QSG_order'=>new EE_Integer_Field('QSG_order', __('Order in which to show the question group','event_espresso'), true, 0),
47
-				'QSG_show_group_name'=>new EE_Boolean_Field('QSG_show_group_name', __('Flag indicating whether to show the group\'s name on the registration page','event_espresso'), false, true),
48
-				'QSG_show_group_desc'=>new EE_Boolean_Field('QSG_show_group_desc', __('Flag indicating whether to show the group\s description on the registration page','event_espresso'), false, false),
49
-				'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', __('Question Group Creator ID', 'event_espresso'), FALSE ),
50
-				'QSG_system'=>new EE_Integer_Field('QSG_system', __('Indicate IF this is a system group and if it is what system group it corresponds to.','event_espresso'), false, 0),
51
-				'QSG_deleted'=>new EE_Trashed_Flag_Field('QSG_deleted', __('Flag indicating this question group was deleted','event_espresso'), false, false)
42
+				'QSG_ID'=>new EE_Primary_Key_Int_Field('QSG_ID', __('Question Group ID', 'event_espresso')),
43
+				'QSG_name'=>new EE_Plain_Text_Field('QSG_name', __('Question Group Name', 'event_espresso'), false, ''),
44
+				'QSG_identifier'=>new EE_Plain_Text_Field('QSG_identifier', __('Text ID for question Group', 'event_espresso'), false, ''),
45
+				'QSG_desc'=>new EE_Full_HTML_Field('QSG_desc', __('Description of Question Group', 'event_espresso'), true, ''),
46
+				'QSG_order'=>new EE_Integer_Field('QSG_order', __('Order in which to show the question group', 'event_espresso'), true, 0),
47
+				'QSG_show_group_name'=>new EE_Boolean_Field('QSG_show_group_name', __('Flag indicating whether to show the group\'s name on the registration page', 'event_espresso'), false, true),
48
+				'QSG_show_group_desc'=>new EE_Boolean_Field('QSG_show_group_desc', __('Flag indicating whether to show the group\s description on the registration page', 'event_espresso'), false, false),
49
+				'QSG_wp_user' => new EE_WP_User_Field('QSG_wp_user', __('Question Group Creator ID', 'event_espresso'), FALSE),
50
+				'QSG_system'=>new EE_Integer_Field('QSG_system', __('Indicate IF this is a system group and if it is what system group it corresponds to.', 'event_espresso'), false, 0),
51
+				'QSG_deleted'=>new EE_Trashed_Flag_Field('QSG_deleted', __('Flag indicating this question group was deleted', 'event_espresso'), false, false)
52 52
 			)
53 53
 		);
54 54
 		$this->_model_relations = array(
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 			'Event_Question_Group'=>new EE_Has_Many_Relation(),
58 58
 			'WP_User' => new EE_Belongs_To_Relation(),
59 59
 		);
60
-		parent::__construct( $timezone );
60
+		parent::__construct($timezone);
61 61
 	}
62 62
 
63 63
 
@@ -69,9 +69,9 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function get_latest_question_group_order() {
71 71
 		$columns_to_select = array(
72
-			'max_order' => array("MAX(QSG_order)","%d")
72
+			'max_order' => array("MAX(QSG_order)", "%d")
73 73
 			);
74
-		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select );
74
+		$max = $this->_get_all_wpdb_results(array(), ARRAY_A, $columns_to_select);
75 75
 		return $max[0]['max_order'];
76 76
 	}
77 77
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.
core/db_models/EEM_Question_Group_Question.model.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -26,33 +26,33 @@
 block discarded – undo
26 26
  *
27 27
  * ------------------------------------------------------------------------
28 28
  */
29
-require_once ( EE_MODELS . 'EEM_Base.model.php' );
30
-require_once( EE_CLASSES . 'EE_Question_Group_Question.class.php');
29
+require_once (EE_MODELS.'EEM_Base.model.php');
30
+require_once(EE_CLASSES.'EE_Question_Group_Question.class.php');
31 31
 class EEM_Question_Group_Question extends EEM_Base {
32 32
 
33 33
   	// private instance of the Attendee object
34 34
 	protected static $_instance = NULL;
35 35
 
36 36
 
37
-	protected function __construct( $timezone = NULL ) {
38
-		$this->singular_item = __('Question Group to Question Link','event_espresso');
39
-		$this->plural_item = __('Question Group to Question Links','event_espresso');
37
+	protected function __construct($timezone = NULL) {
38
+		$this->singular_item = __('Question Group to Question Link', 'event_espresso');
39
+		$this->plural_item = __('Question Group to Question Links', 'event_espresso');
40 40
 		$this->_tables = array(
41
-			'Question_Group_Question'=>new EE_Primary_Table('esp_question_group_question','QGQ_ID')
41
+			'Question_Group_Question'=>new EE_Primary_Table('esp_question_group_question', 'QGQ_ID')
42 42
 		);
43 43
 		$this->_fields = array(
44 44
 			'Question_Group_Question'=>array(
45
-				'QGQ_ID'=>new EE_Primary_Key_Int_Field('QGQ_ID', __('Question Group to Question Link ID','event_espresso')),
46
-				'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group ID','event_espresso'), false, 0, 'Question_Group'),
47
-				'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question Id','event_espresso'), false, 0, 'Question'),
48
-				'QGQ_order' => new EE_Integer_Field('QGQ_order', __('Question Group Question Order', 'event_espresso'), false, 0 )
45
+				'QGQ_ID'=>new EE_Primary_Key_Int_Field('QGQ_ID', __('Question Group to Question Link ID', 'event_espresso')),
46
+				'QSG_ID'=>new EE_Foreign_Key_Int_Field('QSG_ID', __('Question Group ID', 'event_espresso'), false, 0, 'Question_Group'),
47
+				'QST_ID'=>new EE_Foreign_Key_Int_Field('QST_ID', __('Question Id', 'event_espresso'), false, 0, 'Question'),
48
+				'QGQ_order' => new EE_Integer_Field('QGQ_order', __('Question Group Question Order', 'event_espresso'), false, 0)
49 49
 			)
50 50
 		);
51 51
 		$this->_model_relations = array(
52 52
 			'Question_Group'=>new EE_Belongs_To_Relation(),
53 53
 			'Question'=>new EE_Belongs_To_Relation()
54 54
 		);
55
-		parent::__construct( $timezone );
55
+		parent::__construct($timezone);
56 56
 	}
57 57
 
58 58
 
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,6 @@
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3
+}
2 4
 /**
3 5
  * Event Espresso
4 6
  *
Please login to merge, or discard this patch.