本文整理汇总了PHP中Relation::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Relation::model方法的具体用法?PHP Relation::model怎么用?PHP Relation::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Relation
的用法示例。
在下文中一共展示了Relation::model方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getArray
private function getArray(CDbCriteria $criteria)
{
$result = Relation::model()->findAll($criteria);
$users = array();
foreach ($result as $value) {
array_push($users, $value->subUserId);
}
return array_values($users);
}
示例2: actionDeleteRelation
public function actionDeleteRelation()
{
if (isset($_POST['relation_id'])) {
$transaction = Yii::app()->db->beginTransaction();
try {
$relation = Relation::model()->findByPk($_POST['relation_id']);
$rdid = $relation->dataset_id;
$rrdoi = $relation->related_doi;
$rrid = $relation->relationship_id;
$relation2 = Relation::model()->findByAttributes(array('dataset_id' => Dataset::model()->findByAttributes(array('identifier' => $rrdoi))->id, 'related_doi' => Dataset::model()->findByPk($rdid)->identifier, 'relationship_id' => $rrid));
if ($relation->delete() && $relation2->delete()) {
$transaction->commit();
Util::returnJSON(array("success" => true));
} else {
$transaction->rollback();
Util::returnJSON(array("success" => false));
}
} catch (Exception $e) {
$message = $e->getMessage();
Yii::log(print_r($message, true), 'error');
$transaction->rollback();
Util::returnJSON(array("success" => false, "message" => Yii::t("app", "Delete Error.")));
}
}
}
示例3: actionRelatedDoiManagement
public function actionRelatedDoiManagement()
{
if (!isset($_GET['id'])) {
$this->redirect("/user/view_profile");
} else {
$dataset = Dataset::model()->findByPk($_GET['id']);
if (!$dataset) {
$this->redirect("/user/view_profile");
}
if ($dataset->submitter_id != Yii::app()->user->id) {
Yii::app()->user->setFlash('keyword', "You are not the owner of dataset");
$this->redirect("/user/view_profile");
}
$relations = Relation::model()->findAllByAttributes(array('dataset_id' => $dataset->id), array('order' => 'related_doi asc'));
$this->render('relatedDoiManagement', array('model' => $dataset, 'relations' => $relations));
}
}