@@ 1948-1961 (lines=14) @@ | ||
1945 | //if there are query parameters, forget about caching the related model objects. |
|
1946 | if( $query_params ){ |
|
1947 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
|
1948 | }else{ |
|
1949 | //did we already cache the result of this query? |
|
1950 | $cached_results = $this->get_all_from_cache($relationName); |
|
1951 | if ( ! $cached_results ){ |
|
1952 | $related_model_objects = $this->get_model()->get_all_related($this, $relationName, $query_params); |
|
1953 | //if no query parameters were passed, then we got all the related model objects |
|
1954 | //for that relation. We can cache them then. |
|
1955 | foreach($related_model_objects as $related_model_object){ |
|
1956 | $this->cache($relationName, $related_model_object); |
|
1957 | } |
|
1958 | }else{ |
|
1959 | $related_model_objects = $cached_results; |
|
1960 | } |
|
1961 | } |
|
1962 | }else{ |
|
1963 | //this doesn't exist in the DB, so just get the related things from the cache |
|
1964 | $related_model_objects = $this->get_all_from_cache($relationName); |
|
@@ 2017-2027 (lines=11) @@ | ||
2014 | //on a relation which should have an array of objects (because the cache might have an array of objects) |
|
2015 | if ($query_params || ! $this->get_model()->related_settings_for($relationName) instanceof EE_Belongs_To_Relation){ |
|
2016 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2017 | }else{ |
|
2018 | //first, check if we've already cached the result of this query |
|
2019 | $cached_result = $this->get_one_from_cache($relationName); |
|
2020 | if ( ! $cached_result ){ |
|
2021 | ||
2022 | $related_model_object = $this->get_model()->get_first_related($this, $relationName, $query_params); |
|
2023 | $this->cache($relationName,$related_model_object); |
|
2024 | }else{ |
|
2025 | $related_model_object = $cached_result; |
|
2026 | } |
|
2027 | } |
|
2028 | }else{ |
|
2029 | $related_model_object = null; |
|
2030 | //this doesn't exist in the Db, but maybe the relation is of type belongs to, and so the related thing might |