1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* |
5
|
|
|
* Class EEM_Extra_Join |
6
|
|
|
* |
7
|
|
|
* Special model that can be used as a join model between any two models. This |
8
|
|
|
* helps prevent the addition of further tables. |
9
|
|
|
* This model has two foreign keys EXJ_first_model_ID and EXJ_second_model_ID. |
10
|
|
|
* The first always points to the model which is ALPHABETICALLY LOWER than the other |
11
|
|
|
* (ie comes earlier in the alphabet). Eg if an entry in this model's table |
12
|
|
|
* joins an event to a venue, the event id will be in EXJ_first_model_ID, and the |
13
|
|
|
* venue's id will be in EXJ_seonc_model_ID. |
14
|
|
|
* However, if the entry in this model's table joins event to attendee, |
15
|
|
|
* the attendee id will be in EXJ_first_model_ID, and the event id will be in |
16
|
|
|
* EXJ_second_model_ID. |
17
|
|
|
* |
18
|
|
|
* @package Event Espresso |
19
|
|
|
* @subpackage |
20
|
|
|
* @author Mike Nelson |
21
|
|
|
* @since $VID:$ |
22
|
|
|
* |
23
|
|
|
*/ |
24
|
|
|
if (!defined('EVENT_ESPRESSO_VERSION')) { |
25
|
|
|
exit('No direct script access allowed'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
class EEM_Extra_Join extends EEM_Base{ |
29
|
|
|
// private instance of the Extra Join object |
30
|
|
|
protected static $_instance = NULL; |
31
|
|
|
|
32
|
|
|
public function __construct($timezone = NULL) { |
33
|
|
|
$models_this_can_join = array_keys( EE_Registry::instance()->non_abstract_db_models ); |
34
|
|
|
$this->_tables = array( |
|
|
|
|
35
|
|
|
'Extra_Join' => new EE_Primary_Table( 'esp_extra_join', 'EXJ_ID' ), |
36
|
|
|
); |
37
|
|
|
$this->_fields = array( |
|
|
|
|
38
|
|
|
'Extra_Join' => array( |
39
|
|
|
'EXJ_ID' => new EE_Primary_Key_Int_Field( 'EXJ_ID', __( 'Extra Join ID', 'event_espresso' ) ), |
40
|
|
|
'EXJ_first_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_first_model_ID', __( 'First Model ID', 'event_espresso' ), true, 0, $models_this_can_join ), |
|
|
|
|
41
|
|
|
'EXJ_first_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_first_model_name', __( 'First Model Name', 'event_espresso'), true, '', $models_this_can_join ), |
|
|
|
|
42
|
|
|
'EXJ_second_model_ID' => new EE_Foreign_Key_String_Field( 'EXJ_second_model_ID', __( 'Second Model ID', 'event_espresso' ), true, 0, $models_this_can_join ), |
|
|
|
|
43
|
|
|
'EXJ_second_model_name' => new EE_Any_Foreign_Model_Name_Field( 'EXJ_second_model_name', __( 'Second Model Name', 'event_espresso'), true, '', $models_this_can_join ), |
|
|
|
|
44
|
|
|
|
45
|
|
|
) |
46
|
|
|
); |
47
|
|
|
//this model is weird in that it has two foreign key columns which can point to any model/table. |
48
|
|
|
//eg a foreign key to event will be in "EXJ_first_model_ID", provided the other |
49
|
|
|
//model linked to is alphabetically greater than event (eg venue). |
50
|
|
|
//but if the model linked to is alphabetically lower (eg attendee), |
51
|
|
|
//the foreign key to the event will be in "EXJ_second_model_ID" |
52
|
|
|
//so normal usage of foreign keys is weird. So don't define any |
53
|
|
|
//relations to other models because they won't work properly with this model |
54
|
|
|
parent::__construct($timezone); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..