本文整理汇总了PHP中Subject::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Subject::model方法的具体用法?PHP Subject::model怎么用?PHP Subject::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject::model方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionLogin
/**
* Displays the login page
*/
public function actionLogin($sh = '', $t = '')
{
$this->model = new LoginForm();
// if it is ajax validation request
if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
echo CActiveForm::validate($this->model);
Yii::app()->end();
}
// collect user input data
if (isset($_POST['LoginForm'])) {
$this->model->attributes = $_POST['LoginForm'];
// validate user input and redirect to the previous page if valid
if ($this->model->validate() && $this->model->login()) {
//Assign the subject to the new user if he/she registered after adding a subject
if ($sh and $t) {
//Allow asignment only within 15 minutes since subject added
if (SiteLibrary::utc_time() - $t < 900) {
Subject::model()->updateAll(array('user_id' => Yii::app()->user->id), 'time_submitted=:time_submitted AND hash=:hash', array(':time_submitted' => $t, ':hash' => $sh));
}
$this->redirect(array('mysub/' . Yii::app()->user->name));
} else {
$this->redirect(Yii::app()->user->returnUrl);
}
}
}
// display the login form
$this->render('login', array('model' => $this->model));
}
示例2: register
public function register($attr, $image)
{
$check = User::model()->findByAttributes(array('email' => $attr['email']));
if ($check) {
return 'USER_EXIST';
} else {
$model = new User();
$model->setAttributes($attr);
$model->password = md5($attr['password']);
if ($model->save(FALSE)) {
$image_url = NULL;
if (isset($image)) {
$image_url = $image;
}
$model->avatar = $image_url;
$model->save(FALSE);
$subjects = Subject::model()->findAll();
foreach ($subjects as $subject) {
$user_subject = new UserSubject();
$user_subject->subject_id = $subject->subject_id;
$user_subject->user_id = $model->userid;
$user_subject->save(FALSE);
}
return 'SUCCESS';
}
return 'SERVER_ERROR';
}
}
示例3: actionTeacher
public function actionTeacher()
{
if (isset($_GET["id"])) {
$id = StringHelper::filterString($_GET["id"]);
$spCriteria = new CDbCriteria();
$spCriteria->select = "*";
$spCriteria->condition = "teacher_id = :teacher_id";
$spCriteria->params = array(':teacher_id' => $id);
$teacher_current_id = Teacher::model()->findAll($spCriteria);
$subject_teacher = Subject::model()->with(array('subject_teacher' => array('select' => false, 'condition' => 'teacher_id = :teacher_id', 'params' => array(':teacher_id' => $id))))->findAll();
$ratingCriteria = new CDbCriteria();
$ratingCriteria->select = "*";
$ratingCriteria->condition = "teacher_id = :teacher_id";
$ratingCriteria->params = array(":teacher_id" => $id);
$rating = Votes::model()->findAll($ratingCriteria);
$count = count($rating);
if ($teacher_current_id) {
foreach ($teacher_current_id as $detail) {
$title = $detail->teacher_acadamic_title . " " . $detail->teacher_name . "| Bluebee - UET";
$image = $detail->teacher_avatar;
$des = $detail->teacher_description;
$this->pageTitle = $title;
Yii::app()->clientScript->registerLinkTag("image_src", "image/jpeg", $image);
Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title'));
Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image'));
Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description'));
}
$this->render('teacher', array('teacher_detail_info' => Teacher::model()->findAll($spCriteria), 'subject_teacher' => $subject_teacher, 'countVote' => $count));
}
}
}
示例4: actionMore
public function actionMore()
{
Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/enjoy.css');
$city_id = Yii::app()->request->getQuery('city', 0);
$time_sort = Yii::app()->request->getQuery('time_sort', 'DESC');
$price_sort = Yii::app()->request->getQuery('lp_dol');
$criteria = new CDbCriteria();
$criteria->order = 'id DESC';
if (!empty($city_id)) {
$criteria->addCondition('city_id=' . $city_id);
}
if (!empty($time_sort)) {
$criteria->order = 'accessDate ' . $time_sort;
}
if (!empty($price_sort)) {
$criteria->order = 'lp_dol ' . $price_sort;
}
$criteria->addCondition('lp_dol>3000000');
$count = House::model()->count($criteria);
$pager = new CPagination($count);
$pager->pageSize = 10;
$pager->applyLimit($criteria);
$house_list = House::model()->findAll($criteria);
$subject_list = Subject::model()->findAll(array('order' => 'id DESC'));
$cur_city = City::model()->findByPk($city_id);
$data = array('house_list' => $house_list, 'subject_list' => $subject_list, 'cur_city' => $cur_city, 'count' => $count, 'time_sort' => $time_sort, 'price_sort' => $price_sort, 'pages' => $pager);
$this->render('more', $data);
}
示例5: actionViewDocument
public function actionViewDocument()
{
if (isset($_GET['doc_id'])) {
$doc_id = StringHelper::filterString($_GET['doc_id']);
$detail_doc = Doc::model()->findAll(array("select" => "*", "condition" => "doc_id = :doc_id", "params" => array(':doc_id' => $doc_id)));
$spCriteria = new CDbCriteria();
$spCriteria->select = "*";
$spCriteria->condition = "doc_id = :doc_id";
$spCriteria->params = array(':doc_id' => $doc_id);
$subject_doc = SubjectDoc::model()->find($spCriteria);
$spjCriteria = new CDbCriteria();
$spjCriteria->select = "*";
$spjCriteria->condition = "subject_id = :subject_id";
$spjCriteria->params = array(':subject_id' => $subject_doc->subject_id);
$subject = Subject::model()->find($spjCriteria);
$related_doc = Doc::model()->findAll(array("select" => "*", "limit" => "3", "order" => "RAND()"));
foreach ($detail_doc as $detail) {
$title = $detail->doc_name . " | Bluebee - UET";
$this->pageTitle = $title;
if ($detail->doc_type == 3) {
$image = Yii::app()->getBaseUrl(true) . $detail->doc_url;
} else {
$image = $detail->doc_url;
}
$des = $detail->doc_description;
Yii::app()->clientScript->registerMetaTag($title, null, null, array('property' => 'og:title'));
Yii::app()->clientScript->registerMetaTag($image, null, null, array('property' => 'og:image'));
Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:width'));
Yii::app()->clientScript->registerMetaTag(500, null, null, array('property' => 'og:image:height'));
Yii::app()->clientScript->registerMetaTag("website", null, null, array('property' => 'og:type'));
Yii::app()->clientScript->registerMetaTag($des, null, null, array('property' => 'og:description'));
}
$this->render('viewDocument', array('detail_doc' => $detail_doc, 'related_doc' => $related_doc, 'subject' => $subject));
}
}
示例6: searchSubject
public function searchSubject($subject_name)
{
$subCriteria = new CDbCriteria();
$subCriteria->select = "*";
$subCriteria->addSearchCondition('subject_name', $subject_name);
$subject_result = Subject::model()->findAll($subCriteria);
return $subject_result;
}
示例7: actionList
/**
* Kilstázza az adott tantárgyhoz tartozó fájlokat.
* @param int $id A tantárgy azonosítója
*/
public function actionList($id)
{
$model = Subject::model()->findByPk((int) $id);
if ($model == null) {
throw new CHttpException(404, "A kért elem nem található");
}
$this->render('list', array('data' => $model));
}
示例8: GetDependencyTree
public function GetDependencyTree()
{
$Tree = array();
foreach ($this->dependencies as $CurrentDependency) {
$Tree[$CurrentDependency->dependent_subject_id] = Subject::model()->findByPk($CurrentDependency->dependent_subject_id)->GetDependencyTree();
}
return count($Tree) == 0 ? null : $Tree;
}
示例9: loadSubject
/**
* @var string the default layout for the views. Defaults to '//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public function loadSubject($subId)
{
if ($this->_subject === null) {
$this->_subject = Subject::model()->findbyPk($subId);
if ($this->_subject === null) {
throw new CHttpException(404, 'The requested Subject does not exist.');
}
}
return $this->_subject;
}
示例10: actionGetSubjectByUser
public function actionGetSubjectByUser()
{
$request = Yii::app()->request;
try {
$user_id = StringHelper::filterString($request->getQuery('user_id'));
$data = Subject::model()->getSubjectByUser($user_id);
ResponseHelper::JsonReturnSuccess($data, 'success');
} catch (Exception $ex) {
var_dump($ex->getMessage());
}
}
示例11: GetDepTree
function GetDepTree($ID, $Dependencies)
{
$CurrentModel = Subject::model()->findByPk($ID);
print "<li>\n";
print CHtml::link($CurrentModel->name, array('subject/details', 'id' => $CurrentModel->subject_id));
if ($Dependencies != null) {
print "<ul>\n";
foreach ($Dependencies as $Key => $Val) {
GetDepTree($Key, $Val);
}
print "</ul>\n";
}
print "</li>\n";
}
示例12: findSubjectBySubjectGroup
public function findSubjectBySubjectGroup($subject_group_id)
{
$subject = Subject::model()->findAllByAttributes(array('subject_group_id' => $subject_group_id));
$returnArr = array();
foreach ($subject as $item) {
$itemArr = array();
$itemArr['subject_id'] = $item->subject_id;
$itemArr['subject_group_id'] = $item->subject_group_id;
$itemArr['title'] = $item->title;
$itemArr['description'] = $item->description;
$itemArr['subject_group_name'] = $this->findSubjectGroupBySubject($item->subject_id);
//var_dump($this->findSubjectGroupBySubject($item->subject_id)); die;
$returnArr[] = $itemArr;
}
return $returnArr;
}
示例13: actionGetProjects
public function actionGetProjects()
{
$imghost = $this->imgHost;
$results = array();
$postParms = array();
$_POST = (array) json_decode(file_get_contents('php://input'), true);
//error_log("Parms:".$_POST['parms']['id']);
$criteria = new CDbCriteria();
$postParms = !empty($_POST['parms']) ? $_POST['parms'] : array();
if (!empty($postParms['id'])) {
//return single record for detail page
$criteria->addCondition('id="' . $_POST['parms']['id'] . '"');
//$subject = Subject::model()->find($criteria);
$row = Subject::model()->find($criteria);
//foreach($subject as $row){
$result['id'] = $row["id"];
$result['name'] = $row["name"];
$result['summary'] = $row["summary"];
$result['image_list'] = unserialize($row["image_list"]);
$result['layout_list'] = unserialize($row["layout_list"]);
$result['amenities'] = $row["amenities"];
$result['point'] = $row["point"];
$result['room_type_image'] = $row["room_type_image"];
$result['developer_intro'] = $row["developer_intro"];
$result['cityname'] = $row["cityname"];
$result['replaceurl'] = $imghost . "tn_uploads";
//$results[] = $result;
//Return single Array object
echo json_encode($result);
//}
} else {
//Return all recommended project
$criteria->addCondition('recommend=1');
$subject = Subject::model()->findAll($criteria);
foreach ($subject as $row) {
$result['id'] = $row["id"];
$result['name'] = $row["name"];
$result['cityname'] = $row["cityname"];
$result['room_type_image'] = str_replace("uploads", "tn_uploads", $imghost . $row["room_type_image"]);
$results[] = $result;
}
//return object array with multiple elements.
echo json_encode($results);
}
}
示例14: actionEditNews
/**
* Szerkeszti a megadott azonosítójú hírt.
* @param int $id A hír azonosítója.
*/
public function actionEditNews($id)
{
$id = (int) $id;
if (!Yii::app()->user->getId() || Yii::app()->user->level < 1) {
throw new CHttpException(403, 'A funkció használatához be kell jelentkeznie és legalább 1-es szintű hozzáférésre van szüksége');
}
if (isset($_POST["saved"])) {
$model = News::model()->findByPk($id);
$model->title = $_POST["title"];
$model->subject_id = $_POST["subject_id"];
$model->contents = $_POST["contents"];
$model->date_updated = new CDbExpression("NOW()");
$model->save();
$this->redirect(Yii::app()->createUrl("site/index"));
}
$model = News::model()->findByPk($id);
$subjects = Subject::model()->findAll();
$this->render("edit_news", array('data' => $model, 'subjects' => $subjects));
}
示例15: array
<?php
return array("fields" => array("lesson_id" => array("label" => "ID"), "lesson_weeks" => array("label" => "Lesson week"), "lesson_subject" => array("label" => "Lesson of Subject", "type" => "_dropdown", "_list" => array("primary" => "subject_id", "displayAttr" => "subject_name", "src" => function () {
$rows = Subject::model()->findAll();
return $rows;
})), "lesson_doc" => array("label" => "Document of Lesson", "type" => "_dropdown", "_list" => array("primary" => "doc_id", "displayAttr" => "doc_name", "src" => function () {
$rows = Doc::model()->findAll();
return $rows;
}))), "columns" => array("lesson_id", "lesson_weeks", "lesson_subject", "lesson_doc"), "actions" => array("_view" => true, "_edit" => array("lesson_weeks", "lesson_subject", "lesson_doc"), "_delete" => true, "_new" => array("type" => "popup", "attr" => array("lesson_weeks", "lesson_subject", "lesson_doc")), "_search" => array("lesson_weeks", "lesson_subject", "lesson_doc"), "_search_advanced" => array("lesson_weeks", "lesson_subject", "lesson_doc"), "_customButtons" => array()), "default" => array("orderBy" => "lesson_id", "orderType" => "asc", "page" => 1, "per_page" => 10, "search" => "", "search_advanced" => ""), "tableAlias" => "lesson", "title" => "Lesson Manager", "condition" => false, "limit_values" => array(10, 20, 30, 40), "model" => "Lesson", "primary" => "lesson_id", "itemLabel" => "lesson", "additionalFiles" => array());