本文整理汇总了PHP中Note::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Note::model方法的具体用法?PHP Note::model怎么用?PHP Note::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Note
的用法示例。
在下文中一共展示了Note::model方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionNote
/**
* 列出某个课程下的所有笔记
* Enter description here ...
* @param unknown_type $courseId
*/
public function actionNote($courseId)
{
$courseId = intval($courseId);
$course = Course::model()->findByPk($courseId);
$sql = "select n.*,l.id as lessonId from ew_course c inner join ew_lesson l on c.id=l.courseId inner join ew_note n on n.noteableEntityId=l.entityId where c.id={$courseId}";
$notes = Note::model()->findAllBySql($sql);
$dataProvider = new CArrayDataProvider($notes);
$this->render('my_notes', array('dataProvider' => $dataProvider, 'course' => $course));
}
示例2: actionBatchDelete
/**
* Deletes notes in batch mode.
*/
public function actionBatchDelete()
{
if (isset($_POST['deleteNote'])) {
foreach ($_POST['deleteNote'] as $id => $value) {
$model = Note::model()->findByPk($id);
$model->delete();
unlink(Yii::app()->params['notesDir'] . $model->id . '.' . $model->extension);
}
Yii::app()->user->setNotification('success', 'Berkas-berkas berhasil dihapus.');
}
$this->redirect(array('index'));
}
示例3: init
public function init()
{
if (ContactsModule::shouldUpdateLatestActivityDateTimeWhenATaskIsCompleted()) {
$eventHandler = array($this, 'updateContactLatestActivityDateTimeByTask');
Task::model()->attachEventHandler('onAfterSave', $eventHandler);
$this->attachedEventHandlersIndexedByModelClassName['Task'] = array('onAfterSave', $eventHandler);
}
if (ContactsModule::shouldUpdateLatestActivityDateTimeWhenANoteIsCreated()) {
$eventHandler = array($this, 'updateContactLatestActivityDateTimeByNote');
Note::model()->attachEventHandler('onAfterSave', $eventHandler);
$this->attachedEventHandlersIndexedByModelClassName['Note'] = array('onAfterSave', $eventHandler);
}
if (ContactsModule::shouldUpdateLatestActivityDateTimeWhenAnEmailIsSentOrArchived()) {
$eventHandler = array($this, 'updateContactLatestActivityDateTimeByEmailMessage');
EmailMessage::model()->attachEventHandler('onAfterSave', $eventHandler);
$this->attachedEventHandlersIndexedByModelClassName['EmailMessage'] = array('onAfterSave', $eventHandler);
}
if (ContactsModule::shouldUpdateLatestActivityDateTimeWhenAMeetingIsInThePast()) {
$eventHandler = array($this, 'resolveModelLatestActivityDateTimeProcessFlagByMeeting');
Meeting::model()->attachEventHandler('onBeforeSave', $eventHandler);
$this->attachedEventHandlersIndexedByModelClassName['Meeting'] = array('onBeforeSave', $eventHandler);
}
}
示例4: getNoteCount
/**
* 获取反对票数量
*/
public function getNoteCount()
{
return Note::model()->count("noteableEntityId=:entityId and value<=0", array(':entityId' => $this->getOwner()->entityId));
}
示例5: saveNoteTypeIds
public function saveNoteTypeIds($noteIds = [], $noteTypeId)
{
if (!$noteTypeId) {
throw new CHttpException(404, "Note type is not found");
}
$r = Note::model()->updateAll(['not_row' => $noteTypeId], "not_id in (" . implode(",", $noteIds) . ")");
}
示例6: saveClient
private function saveClient(Client $model)
{
$this->prepareModel($model);
if (isset($_POST['Client']) && $_POST['Client']) {
$_POST['Client']['propertyTypesIds'] = isset($_POST['Client']['propertyTypesIds']) ? $_POST['Client']['propertyTypesIds'] : [];
$_POST['Client']['propertyCategoryIds'] = isset($_POST['Client']['propertyCategoryIds']) ? $_POST['Client']['propertyCategoryIds'] : [];
$model->attributes = $_POST['Client'];
if ($model->isNewRecord) {
$model->scenario = 'validPhoneOnInsert';
}
$generalNoteIds = isset($_POST['noteId-' . Note::TYPE_CLIENT_GENERAL]) ? $_POST['noteId-' . Note::TYPE_CLIENT_GENERAL] : [];
$generalNote = isset($_POST[Note::TYPE_CLIENT_GENERAL]) ? $_POST[Note::TYPE_CLIENT_GENERAL] : [];
$reqNoteIds = isset($_POST['noteId-' . Note::TYPE_CLIENT_REQ]) ? $_POST['noteId-' . Note::TYPE_CLIENT_REQ] : [];
$reqNote = isset($_POST[Note::TYPE_CLIENT_REQ]) ? $_POST[Note::TYPE_CLIENT_REQ] : [];
$telephones = isset($_POST['telephones']) ? $_POST['telephones'] : [];
$existingPhones = Telephone::model()->findAllByPk(array_filter($telephones['id']), ['index' => 'tel_id']);
if (isset($telephones['number'][0]) && $telephones['number'][0]) {
$phone = new Telephone();
$phone->tel_number = $telephones['number'][0];
$phone->tel_type = $telephones['type'][0];
$model->_newPhones = [$phone];
}
$model->addressID = isset($_POST['primaryAddress']['id']) ? $_POST['primaryAddress']['id'] : 0;
$model->secondAddressID = isset($_POST['secondAddress']['id']) ? $_POST['secondAddress']['id'] : 0;
if ($model->save()) {
/** @var $existingPhones Telephone */
foreach ($telephones['number'] as $key => $number) {
$phoneId = $telephones['id'][$key];
$type = $telephones['type'][$key];
if (isset($existingPhones[$phoneId])) {
$phone = $existingPhones[$phoneId];
} else {
$phone = new Telephone();
}
if ($number) {
$phone->tel_cli = $model->cli_id;
$phone->tel_number = $number;
$phone->tel_type = $type;
$phone->save();
} else {
if (!$phone->isNewRecord) {
$phone->delete();
}
}
}
$model->saveAreas(isset($_POST['Client']['matchingPostcode']) ? $_POST['Client']['matchingPostcode'] : []);
$model->saveFeatures(isset($_POST['Client']['feature']) ? $_POST['Client']['feature'] : []);
if ($generalNoteIds) {
Note::model()->saveNoteTypeIds($generalNoteIds, $model->cli_id);
}
if ($reqNoteIds) {
Note::model()->saveNoteTypeIds($reqNoteIds, $model->cli_id);
}
if ($generalNote) {
$generalNote['not_type'] = Note::TYPE_CLIENT_GENERAL;
Note::model()->saveNote($generalNote, $model->cli_id);
}
if ($reqNote) {
$reqNote['not_type'] = Note::TYPE_CLIENT_REQ;
Note::model()->saveNote($reqNote, $model->cli_id);
}
if (isset($_POST['Client']['saveProceed']) && $_POST['Client']['saveProceed']) {
$this->redirect([$this->createUrl('appointmentBuilder/clientSelected', ['clientId' => $model->cli_id])]);
} else {
Yii::app()->user->setFlash('client-update-success', 'Updated Successfully');
$this->redirect(array('Update', 'id' => $model->cli_id, 'useClient' => isset($_GET['useClient']) && $_GET['useClient'] ? 1 : 0));
}
}
}
}
示例7: actionSaveNoteBlurb
public function actionSaveNoteBlurb()
{
if (!isset($_POST['noteId'], $_POST['noteBlurb'])) {
throw new CHttpException(400, 'Wrong request');
}
if ($_POST['noteId']) {
$model = Note::model()->findByPk($_POST['noteId']);
if (!$model) {
throw new CHttpException(400, 'Wrong request');
}
} elseif (isset($_POST['noteType'], $_POST['noteTypeId'])) {
$model = new Note();
$model->not_type = $_POST['noteType'];
$model->not_row = $_POST['noteTypeId'];
} else {
throw new CHttpException(400, 'Wrong request');
}
$model->not_blurb = $_POST['noteBlurb'];
$model->save();
echo $model->not_id;
}
示例8: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer $id the ID of the model to be loaded
* @return Note the loaded model
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Note::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例9: saveNote
/**
* @param $data
* @param $noteType
* @param $instruction
*/
private function saveNote($data, $noteType, $instruction)
{
if (!isset($data[$noteType]['not_blurb']) || !$data[$noteType]['not_blurb']) {
return;
}
$model = new Note();
if (isset($data[$noteType]['not_id']) && $data[$noteType]['not_id']) {
$model = Note::model()->findByPk($data[$noteType]['not_id']);
}
$model->not_blurb = $data[$noteType]['not_blurb'];
$model->not_row = $instruction->dea_id;
$model->not_type = $noteType;
if (!$model->save()) {
Yii::app()->user->setFlash('error', 'note [type = ' . $noteType . '] is not saved.');
}
}
示例10: testUpdateInvalid
/**
* Tests the note update action with invalid input.
*/
public function testUpdateInvalid()
{
$model = $this->notes('note3');
// Empty title
$fakeNote = Note::model()->findByPk($model->id);
$fakeNote->title = null;
$this->assertFalse($fakeNote->validate());
// Lengthy title
$fakeNote = Note::model()->findByPk($model->id);
Yii::import('ext.randomness.*');
$fakeNote->title = Randomness::randomString(Note::MAX_TITLE_LENGTH + 1);
$this->assertFalse($fakeNote->validate());
// Empty description
$fakeNote = Note::model()->findByPk($model->id);
$fakeNote->description = null;
$this->assertFalse($fakeNote->validate());
}
示例11: loadModel
/**
* Loads the note model.
* @param int $id the note id
* @return Note the note object associated with the given id
*/
public function loadModel($id)
{
$model = Note::model()->findByPk($id);
if ($model === NULL) {
throw new CHttpException(404, 'Berkas catatan yang dimaksud tidak ada.');
}
return $model;
}