| @@ 169-175 (lines=7) @@ | ||
| 166 | * @return boolean if $save=true, NULL is $save=false |
|
| 167 | */ |
|
| 168 | function set_object($object, $save = TRUE ) { |
|
| 169 | if($object instanceof EE_Base_Class){ |
|
| 170 | $this->set_OBJ_type($object->get_model()->get_this_model_name()); |
|
| 171 | $this->set_OBJ_ID($object->ID()); |
|
| 172 | }else{ |
|
| 173 | $this->set_OBJ_type(NULL); |
|
| 174 | $this->set_OBJ_ID(NULL); |
|
| 175 | } |
|
| 176 | if($save){ |
|
| 177 | return $this->save(); |
|
| 178 | }else{ |
|
| @@ 1853-1864 (lines=12) @@ | ||
| 1850 | } |
|
| 1851 | $this->cache( $relationName, $otherObjectModelObjectOrID, $cache_id ); |
|
| 1852 | } |
|
| 1853 | if( $otherObject instanceof EE_Base_Class ) { |
|
| 1854 | //fix the reciprocal relation too |
|
| 1855 | if( $otherObject->ID() ) { |
|
| 1856 | //its saved so assumed relations exist in the DB, so we can just |
|
| 1857 | //clear the cache so future queries use the updated info in the DB |
|
| 1858 | $otherObject->clear_cache( $this->get_model()->get_this_model_name(), null, true ); |
|
| 1859 | } else { |
|
| 1860 | ||
| 1861 | //it's not saved, so it caches relations like this |
|
| 1862 | $otherObject->cache( $this->get_model()->get_this_model_name(), $this ); |
|
| 1863 | } |
|
| 1864 | } |
|
| 1865 | return $otherObject; |
|
| 1866 | } |
|
| 1867 | ||