Changeset 1534
- Timestamp:
- 12/14/2007 12:52:49 PM (11 months ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
modules/auth/models/user.php (modified) (1 diff)
-
system/libraries/ORM.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/auth/models/user.php
r1431 r1534 76 76 77 77 /** 78 * Removes all roles for this user when the object is deleted.78 * Allows a model to be loaded by username or email address. 79 79 */ 80 public function delete()81 {82 $where = array($this->class.'_id' => $this->object->id);83 $table = $this->related_table('roles');84 85 if ($return = parent::delete())86 {87 // Remove users<>roles relationships88 self::$db89 ->where($where)90 ->delete($table);91 }92 93 return $return;94 }95 96 80 protected function where_key($id = NULL) 97 81 { 98 if ( is_string($id) AND ! is_numeric($id))82 if ( ! empty($id) AND is_string($id) AND ! ctype_digit($id)) 99 83 { 100 84 return valid::email($id) ? 'email' : 'username'; -
trunk/system/libraries/ORM.php
r1490 r1534 546 546 return FALSE; 547 547 548 if ( ! empty($this->has_any_belongs_to_many)) 549 { 550 // Foreign WHERE for this object 551 $where = array($this->class.'_id' => $this->object->id); 552 553 foreach($this->has_and_belongs_to_many as $table) 554 { 555 // Delete all many<>many relationships for this object 556 self::$db->delete($this->table_name.'_'.$table, $where); 557 } 558 } 559 548 560 // WHERE for this object 549 561 $where = array('id' => $this->object->id);
