|
@@ 1513-1523 (lines=11) @@
|
| 1510 |
|
}else{//PK is NOT auto-increment |
| 1511 |
|
//so check if one like it already exists in the db |
| 1512 |
|
if( $this->get_model()->exists_by_ID( $this->ID() ) ){ |
| 1513 |
|
if( WP_DEBUG && ! $this->in_entity_map() ){ |
| 1514 |
|
throw new EE_Error( |
| 1515 |
|
sprintf( |
| 1516 |
|
__( 'Using a model object %1$s that is NOT in the entity map, can lead to unexpected errors. You should either: %4$s 1. Put it in the entity mapper by calling %2$s %4$s 2. Discard this model object and use what is in the entity mapper %4$s 3. Fetch from the database using %3$s', 'event_espresso' ), |
| 1517 |
|
get_class($this), |
| 1518 |
|
get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
| 1519 |
|
get_class( $this->get_model() ) . '::instance()->get_one_by_ID()', |
| 1520 |
|
'<br />' |
| 1521 |
|
) |
| 1522 |
|
); |
| 1523 |
|
} |
| 1524 |
|
$results = $this->get_model()->update_by_ID($save_cols_n_values, $this->ID()); |
| 1525 |
|
}else{ |
| 1526 |
|
$results = $this->get_model()->insert($save_cols_n_values); |
|
@@ 2423-2438 (lines=16) @@
|
| 2420 |
|
public function refresh_from_db(){ |
| 2421 |
|
if( $this->ID() && $this->in_entity_map() ){ |
| 2422 |
|
$this->get_model()->refresh_entity_map_from_db( $this->ID() ); |
| 2423 |
|
}else{ |
| 2424 |
|
//if it doesn't have ID, you shouldn't be asking to refresh it from teh database (because its not in the database) |
| 2425 |
|
//if it has an ID but it's not in the map, and you're asking me to refresh it |
| 2426 |
|
//that's kinda dangerous. You should just use what's in the entity map, or add this to the entity map if there's |
| 2427 |
|
//absolutely nothing in it for this ID |
| 2428 |
|
if( WP_DEBUG ) { |
| 2429 |
|
throw new EE_Error( |
| 2430 |
|
sprintf( |
| 2431 |
|
__( 'Trying to refresh a model object with ID "%1$s" that\'s not in the entity map? First off: you should put it in the entity map by calling %2$s. Second off, if you want what\'s in the database right now, you should just call %3$s yourself and discard this model object.', 'event_espresso' ), |
| 2432 |
|
$this->ID(), |
| 2433 |
|
get_class( $this->get_model() ) . '::instance()->add_to_entity_map()', |
| 2434 |
|
get_class( $this->get_model() ) . '::instance()->refresh_entity_map()' |
| 2435 |
|
) |
| 2436 |
|
); |
| 2437 |
|
} |
| 2438 |
|
} |
| 2439 |
|
} |
| 2440 |
|
|
| 2441 |
|
|