本文整理汇总了PHP中Operation::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Operation::model方法的具体用法?PHP Operation::model怎么用?PHP Operation::model使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operation
的用法示例。
在下文中一共展示了Operation::model方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionIndex
public function actionIndex()
{
$operation = Operation::model()->findByAttributes(['module' => $this->getModule()->getId(), 'controller' => $this->getId(), 'action' => $this->getAction()->getId()]);
if ($operation->getAttribute('level') == 1) {
$maxLevel = 2;
} else {
$maxLevel = PHP_INT_MAX;
}
$operation = $this->auth->getOperationByPk($operation->getAttribute('id'));
$child = $operation->getChild();
usort($child, function ($a, $b) {
if ($a->getRawData('sort') == $b->getRawData('sort')) {
return 0;
}
if ($a->getRawData('sort') < $b->getRawData('sort')) {
return 1;
} else {
return 0;
}
});
$nav = array();
foreach ($child as $item) {
if ($item->getStatus() || $item->getLevel() > $maxLevel) {
continue;
}
$nav[] = [$item->getName(), $this->app->createUrl($item->getModule() . '/' . $item->getController() . '/' . $item->getAction())];
}
$this->render('/public/nav', ['nav' => $nav]);
}
示例2: 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 the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Operation::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例3: actionDisplayOperation
public function actionDisplayOperation($id = null)
{
$model = Record::model()->findAllByAttributes(array('operation_id' => $id));
$values = CHtml::listData($model, 'port_id', 'value', 'timestamp');
$jsonarray = array();
foreach ($values as $date => $value) {
$jsonarray[] = array_merge(array($date), $value);
}
$model = Operation::model()->with('iface')->findByPK($id);
$model->nextPrev();
$this->render('displayOperation', array('values' => $jsonarray, 'operation' => $model));
}
示例4: deleteOldOperations
/**
* This method deletes all completed operations not in top count.
* @param type $topCount Count of recent operations to keep.
* @return void
*/
public static function deleteOldOperations($topCount = 1000)
{
// Get total count of records
$totalCount = Operation::model()->count();
$limitCount = $totalCount - $topCount;
if ($limitCount <= 0) {
return;
}
// Do nothing
// Select the oldest operation records for deleting
$criteria = new CDbCriteria();
$criteria->select = '*';
$criteria->compare('status', '<>' . self::STATUS_STARTED);
$criteria->order = 'timestamp DESC';
$criteria->limit = $limitCount;
$ops = Operation::model()->findAll($criteria);
foreach ($ops as $op) {
$op->delete();
}
}
示例5: testDeleteOldOperations
public function testDeleteOldOperations()
{
// Create 10 operations
$i = 0;
for ($i = 0; $i < 10; $i++) {
$op = new Operation();
$op->status = Operation::STATUS_SUCCEEDED;
$op->timestamp = time();
$op->srcid = $i;
$op->cmdid = '1234.' . $i;
$op->optype = Operation::OPTYPE_IMPORTPDB;
$op->operand1 = "C:\\Program Files\\Apache Software Foundations\\htdocs\\crashfix\\protected\\data\\debugInfo\\CrashRpt{$i}.pdb";
$op->operand2 = "C:\\Program Files\\Apache Software Foundations\\htdocs\\crashfix\\protected\runtime\tmp1234{$i}.tmp";
$this->assertTrue($op->save());
}
// Delete old operations
Operation::deleteOldOperations(5);
// Expect there are 5 ops now
$count = Operation::model()->count();
$this->assertTrue($count == 5);
}
示例6: save
public function save()
{
try {
if ($this->id) {
$model = Operation::model()->findByPk($this->id);
if (empty($model)) {
throw new CDbException('参数出错', 1, []);
}
} else {
$model = new Operation();
}
$model->attributes = ['name' => $this->name, 'description' => $this->description, 'module' => $this->module, 'controller' => $this->controller, 'action' => $this->action, 'status' => $this->status, 'sort' => $this->sort];
if ($model->save() === false) {
throw new CDbException('更新用户出错', 2, $model->getErrors());
}
} catch (CDbException $e) {
$this->addErrors($e->errorInfo);
return false;
}
return true;
}
示例7: view
public function view()
{
$roleId = $this->request->getPost('role', 0);
$role = $this->auth->getRoleByPk($roleId);
if ($role == false) {
$this->response(404, '参数错误');
} else {
$operations = Operation::model()->findAll(['condition' => '`level`=2']);
$opera = [];
foreach ($operations as $operation) {
$auth = $this->auth->getOperationByPk($operation->getAttribute('id'));
$opera[] = ['data' => $auth, 'child' => $auth->getChild()];
}
$assigns = $role->getAssigns();
$assign = [];
foreach ($assigns as $item) {
if ($item !== false) {
$assign[] = $item->getId();
}
}
$this->render('assign', ['opera' => $opera, 'role' => $role, 'assign' => $assign]);
}
}
示例8: model
protected function model()
{
return Operation::model();
}
示例9: model
public function model()
{
return Operation::model();
}
示例10: checkDebugInfoDeletionOperations
private function checkDebugInfoDeletionOperations()
{
Yii::log('Checking debug info deletion operations in progress...', 'info');
// Get the list of debug info deletion operations that were started recently
$criteria = new CDbCriteria();
$criteria->select = '*';
$criteria->condition = 'optype=:optype AND status=:status';
$criteria->params = array(':optype' => Operation::OPTYPE_DELETE_DEBUG_INFO, ':status' => Operation::STATUS_STARTED);
$criteria->limit = 500;
$operations = Operation::model()->findAll($criteria);
if ($operations == Null) {
Yii::log('There are no operations in progress', 'info');
} else {
Yii::log('Found ' . count($operations) . ' operations in progress', 'info');
}
foreach ($operations as $op) {
$cmdRetCode = -1;
$cmdRetMsg = "";
$check = $this->checkAssyncCommand($op->cmdid, $cmdRetCode, $cmdRetMsg);
if ($check == self::CAC_STILL_RUNNING) {
continue;
}
// Command is still running
$opStatus = Operation::STATUS_FAILED;
if ($check == self::CAC_COMPLETED) {
// The operation seems to be completed.
$debugInfoId = $op->srcid;
$debugInfo = DebugInfo::model()->findByPk($debugInfoId);
if ($debugInfo != null) {
// Delete debug info record
$debugInfo->delete();
// Set operation status to 'Succeeded'
$opStatus = Operation::STATUS_SUCCEEDED;
}
} else {
if ($check == self::CAC_ERROR) {
// Delete debug info record
$debugInfoId = $op->srcid;
$debugInfo = DebugInfo::model()->findByPk($debugInfoId);
if ($debugInfo != null) {
$debugInfo->delete();
}
// Set operation status to 'Failed'
$opStatus = Operation::STATUS_FAILED;
}
}
// Finish operation
$this->finalizeOperation($op, $opStatus);
}
Yii::log("Finished checking debug info deletion operations in progress.", "info");
}