/** * Validates the attribute of the object. * If there is any error, the error message is added to the object. * @param CModel $object the object being validated * @param string $attribute the attribute being validated * @return true|false */ protected function validateAttribute($object, $attribute) { if (empty($this->modelClass)) { $this->modelClass = get_class($object); } $tmpObj = ECassandraCF::model($this->modelClass)->getIndexedSlices($attribute, $object->{$attribute}); // No record found if ($tmpObj === null) { return true; } // A record existed if (empty($this->message)) { $this->message = 'This value is not unique'; } $this->addError($object, $attribute, $this->message); return false; }
/** * Returns the static model of the specified AR class. * @param string $className active record class name. * @return User the static model class */ public static function model($className = __CLASS__) { return parent::model($className); }
/** * Initializes this model. * This method is invoked when an ECassandraCF is newly created. * You should override this method to provide code that is needed to initialize the model. * For example, to specify a column family: * <pre> * * </pre> */ public function init() { if (empty($this->_cfName)) { $this->_cfName = $this->tableName(); if (self::$_connectionPool === null) { self::$_connectionPool = Yii::app()->getComponent('cassandradb')->getConnectionPool(); } if (strpos($this->_cfName, '{{') !== false) { $this->_cfName = str_replace('{{', '', $this->_cfName); $this->_cfName = str_replace('}}', '', $this->_cfName); $this->_cfName = Yii::app()->getComponent('cassandradb')->tablePrefix . $this->_cfName; } } if (!empty($this->_cfName) && !is_object($this->_columnFamily)) { $this->_columnFamily = new ColumnFamily(self::$_connectionPool, $this->_cfName); } //parent::init(); }
/** * Sets a setting variable. * @param string $name The variable name * @param mixed $value The variable value * @return true */ public function __set($name, $value) { parent::__set($name, $value); return $this->insert($name, array('value' => $value)); }
public function __construct($objectId, $objectType, $scenario = 'insert') { $this->_objectId = $objectId; $this->_objectType = $objectType; parent::__construct($scenario); }