forked from gigascience/gigadb-website
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
merging identical authors (#49): updated the database schema and mode…
…l classes to support the functionality
- Loading branch information
Rija Menage
committed
Mar 22, 2018
1 parent
a332f26
commit 6726f17
Showing
5 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<?php | ||
|
||
/** | ||
* This is the model class for table "author_rel". | ||
* | ||
* The followings are the available columns in table 'author_rel': | ||
* @property integer $id | ||
* @property integer $author_id | ||
* @property integer $related_author_id | ||
* @property integer $relationship_id | ||
* | ||
* The followings are the available model relations: | ||
* @property Relationship $relationship | ||
* @property Author $author | ||
*/ | ||
class AuthorRel extends CActiveRecord | ||
{ | ||
/** | ||
* Returns the static model of the specified AR class. | ||
* @param string $className active record class name. | ||
* @return AuthorRel the static model class | ||
*/ | ||
public static function model($className=__CLASS__) | ||
{ | ||
return parent::model($className); | ||
} | ||
|
||
/** | ||
* @return string the associated database table name | ||
*/ | ||
public function tableName() | ||
{ | ||
return 'author_rel'; | ||
} | ||
|
||
/** | ||
* @return array validation rules for model attributes. | ||
*/ | ||
public function rules() | ||
{ | ||
// NOTE: you should only define rules for those attributes that | ||
// will receive user inputs. | ||
return array( | ||
array('author_id, related_author_id', 'required'), | ||
array('author_id, related_author_id, relationship_id', 'numerical', 'integerOnly'=>true), | ||
// The following rule is used by search(). | ||
// Please remove those attributes that should not be searched. | ||
array('id, author_id, related_author_id, relationship_id', 'safe', 'on'=>'search'), | ||
); | ||
} | ||
|
||
/** | ||
* @return array relational rules. | ||
*/ | ||
public function relations() | ||
{ | ||
// NOTE: you may need to adjust the relation name and the related | ||
// class name for the relations automatically generated below. | ||
return array( | ||
'relationship' => array(self::BELONGS_TO, 'Relationship', 'relationship_id'), | ||
'author' => array(self::BELONGS_TO, 'Author', 'author_id'), | ||
); | ||
} | ||
|
||
/** | ||
* @return array customized attribute labels (name=>label) | ||
*/ | ||
public function attributeLabels() | ||
{ | ||
return array( | ||
'id' => 'ID', | ||
'author_id' => 'Author', | ||
'related_author_id' => 'Related Author', | ||
'relationship_id' => 'Relationship', | ||
); | ||
} | ||
|
||
/** | ||
* Retrieves a list of models based on the current search/filter conditions. | ||
* @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions. | ||
*/ | ||
public function search() | ||
{ | ||
// Warning: Please modify the following code to remove attributes that | ||
// should not be searched. | ||
|
||
$criteria=new CDbCriteria; | ||
|
||
$criteria->compare('id',$this->id); | ||
$criteria->compare('author_id',$this->author_id); | ||
$criteria->compare('related_author_id',$this->related_author_id); | ||
$criteria->compare('relationship_id',$this->relationship_id); | ||
|
||
return new CActiveDataProvider($this, array( | ||
'criteria'=>$criteria, | ||
)); | ||
} | ||
|
||
public function behaviors() { | ||
return array( | ||
'ActiveRecordLogableBehavior' => 'application.behaviors.DatasetRelatedTableBehavior', | ||
); | ||
} | ||
|
||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
table: author_rel | ||
from: null | ||
to: ram_1 | ||
depends: | ||
- [author, stpn_1] | ||
- [relation, stpn_1] | ||
sql: | | ||
CREATE TABLE author_rel ( | ||
id SERIAL NOT NULL PRIMARY KEY, | ||
author_id INTEGER NOT NULL REFERENCES author(id) ON DELETE CASCADE, | ||
related_author_id INTEGER NOT NULL REFERENCES author(id) ON DELETE CASCADE, | ||
relationship_id INTEGER NOT NULL REFERENCES relation(id) ON DELETE CASCADE, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters