/** * Finds all active records satisfying the specified condition, selecting only the requested * attributes and, if specified, the primary keys. * See {@link CActiveRecord::find} for detailed explanation about $condition and $params. * #MethodTracker * This method is based on {@link CActiveRecord::findAll}, from version 1.1.7 (r3135). Changes: * <ul> * <li>Selects only the specified attributes.</li> * <li>Detects and selects the representing column.</li> * <li>Detects and selects the PK attribute.</li> * </ul> * @param string|array $attributes The names of the attributes to be selected. * Optional. If not specified, the {@link representingColumn} will be used. * @param boolean $withPk Specifies if the primary keys will be selected. * @param mixed $condition Query condition or criteria. * @param array $params Parameters to be bound to an SQL statement. * @return array List of active records satisfying the specified condition. An empty array is returned if none is found. */ public function findAllAttributes($attributes = null, $withPk = false, $condition = '', $params = array()) { $criteria = $this->getCommandBuilder()->createCriteria($condition, $params); if ($attributes === null) { $attributes = $this->representingColumn(); } if ($withPk) { $pks = self::model(get_class($this))->getTableSchema()->primaryKey; if (!is_array($pks)) { $pks = array($pks); } if (!is_array($attributes)) { $attributes = array($attributes); } $attributes = array_merge($pks, $attributes); } $criteria->select = $attributes; return parent::findAll($criteria); }
/** * Encrypt password on create and on update: overload beforeSave function */ protected function beforeSave() { if ($this->isNewRecord) { $this->Date_Added = date("Y-m-d H:i:s", time()); $this->IP_Adress = $this->getIP(); } else { $this->Date_Modified = date("Y-m-d H:i:s", time()); $this->IP_Adress = $this->getIP(); } if (parent::beforeSave()) { $this->Password = $this->hash($this->Password); return true; } return false; }