- open cmd (as an admin)
- type:
mklink /d linkpath targetpath
example:
mklink /d c:\easytoremember c:\users\neil\local\applicationdata\temp\hardtoremember
mklink /d linkpath targetpath
mklink /d c:\easytoremember c:\users\neil\local\applicationdata\temp\hardtoremember
class OCCActiveRecord extends CActiveRecord{ public $checksum = null; public function afterFind(){ /* get a checksum of all the attribute values after reading a record from db */ $this->checksum = md5(implode('', $this->getAttributes(false))); parent::afterFind(); } public function rules(){ /* use an exist validator to make sure that a record with the same checksum is still in db. if it's been modified, then checksums will be different */ return array( array('id', 'exist', 'message'=>'This record was modified after you read it', 'on'=>'update', 'criteria'=>array('condition'=>'md5(concat('.implode(',',$this->attributeNames()).'))=:checksum', 'params'=>array('checksum'=>$this->checksum))) ); } }Just a rough sketch, but you get the idea.
CREATE TABLE `tbl_party` ( `id` int(11) NOT NULL AUTO_INCREMENT, `type` char(1) NOT NULL comment 'p=person,o=organization', `name` varchar(255) NOT NULL comment 'surname if a person', `given_name` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`) ) ;
class Party extends CActiveRecord { public static function model($className=__CLASS__){ return parent::model($className); } public function tableName(){ return 'tbl_party'; } public function relations(){ return array( ); } public function rules(){ return array( array('name,type','required'), array('type','in', 'range'=>array('o','p')) ); } } class Person extends Party { /* this is required for subtypes */ public static function model($className=__CLASS__){ return parent::model($className); } public function defaultScope(){ /* only read Parties that are People */ return array( 'condition'=>"type='p'" ); } public function relations(){ /* combine parent and own relations. can have 'People' only relations */ $parentRelations = parent::relations(); $myRelations = array( ); return array_merge($myRelations, $parentRelations); } public function rules(){ /* combine parent and own rules */ $parentRules = parent::rules(); $myRules = array( array('type', 'default', 'value'=>'p'), /* set type to Person */ array('type', 'in', 'range'=>array('p')), /* allow only Person type */ array('given_name', 'required') /* new rule for this subtype only */ ); /* you want to apply parent rules last, delete them here if necessary */ return array_merge($myRules, $parentRules); } } class Organization extends Party { public static function model($className=__CLASS__){ return parent::model($className); } public function defaultScope(){ return array( 'condition'=>"type='o'" ); } public function relations(){ $parentRelations = parent::relations(); $myRelations = array( ); return array_merge($myRelations, $parentRelations); } public function rules(){ $parentRules = parent::rules(); $myRules = array( array('type', 'default', 'value'=>'o'), array('type', 'in', 'range'=>array('o')) ); /* you want to apply parent rules last. delete them if necessary */ return array_merge($myRules, $parentRules); } }