/** * Create the object * @param array $exclude Attributes not to set * @return boolean */ public function Create($exclude = array()) { // Get the next value if there is none if (!$this->iget('value')) { $this->iset('value', 1 + (int) $this->getValue(array('select' => 'MAX(value)', 'where' => array(array('module_id', $this->iget('module_id')))))); } // Call parent return parent::Create($exclude); }
public function __construct() { parent::__construct(); $this->set('date_created', date('d/m/Y')); $this->set('database', $this->db->getDatabaseName()); if (defined('AUTHOR_NAME')) { $this->set('author', AUTHOR_NAME); } if (defined('AUTHOR_EMAIL')) { $this->set('email', AUTHOR_EMAIL); } if (defined('AUTHOR_URL')) { $this->set('link', AUTHOR_URL); } if (defined('AUTHOR_COPYRIGHT')) { $this->set('copyright', AUTHOR_COPYRIGHT); } }
/** * Update a user * @param array $exclude Attributes not to update * @param \PDO $db Database connection to use, default to master resource * @return boolean */ public function Update($exclude = array(), &$db = FALSE) { // Check email is unique if (!$this->uniqueEmail()) { // Set message new \Sonic\Message('error', 'The email address `' . $this->iget('email') . '` is already assigned to an account! Please choose another.'); // Return FALSE return FALSE; } // Hash password $password = $this->iget('password'); // If password is not in exclude array if (!in_array('password', $exclude)) { // If no password is set if (!$this->attributeHasValue('password')) { // Get the existing password hash $this->readAttribute('password'); } else { // Hash password $this->iset('password', self::_Hash($password)); } } // Call parent method $parent = parent::Update($exclude, $db); // Reset password $this->iset('password', $password); // Return return $parent; }
/** * Delete an object in the database and memcached * @param mixed $pkValue Primary key value * @return boolean */ public function delete($pkValue = FALSE) { // If there is no key value passed set it if ($pkValue === FALSE) { $pkValue = $this->iget(static::$pk); } // Call parent method $parent = parent::delete($pkValue); if ($parent === FALSE) { return FALSE; } // If there is a memcached object delete from the cache if ($this->memcached instanceof \Memcached) { $this->memcached->delete(static::_getMemcachedID($pkValue)); } // Return return $parent; }