/** * Save * */ function save() { parent::save(); // If more than 10 passwords, delete oldest $passwords = ContactPasswords::findAll(array('conditions' => array('`contact_id` = ?', $this->getContactId()))); if (count($passwords) > 10) { $oldest = ContactPasswords::getOldestContactPassword($this->getContactId()); $oldest[0]->delete(); } }
/** * Return newest contact passwords for all contacts * * @access public * @return array */ static function getNewestContactPasswords() { return ContactPasswords::findAll(array('order' => 'password_date desc', 'group by' => 'contact_id')); // findAll }