本文整理汇总了PHP中Operation类的典型用法代码示例。如果您正苦于以下问题:PHP Operation类的具体用法?PHP Operation怎么用?PHP Operation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Operation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionOperation
public function actionOperation()
{
$post = file_get_contents("php://input");
$postData = CJSON::decode($post, true);
$this->_device->ifaces[$postData['iface_id']]->saveAttributes(array('lastactivity' => $postData['start']));
$operation = new Operation();
$postData['alarm'] = $postData['alarm'] ? 1 : 0;
$operation->attributes = $postData;
$transaction = Yii::app()->db->beginTransaction();
try {
$operation->save();
$operation_id = $operation->id;
foreach ($postData['records'] as $record) {
$record['operation_id'] = $operation_id;
$recordModel = new Record();
$recordModel->attributes = $record;
$recordModel->save();
}
$transaction->commit();
$this->_sendResponse(200);
} catch (Exception $e) {
$transaction->rollBack();
$this->_sendResponse(400);
}
}
示例2: assertOperation
/**
* Сравнить Operation с ожидаемым массивом значений
*/
private function assertOperation(array $expected, Operation $op)
{
ksort($expected);
$actual = array_intersect_key($op->toArray(false), $expected);
ksort($actual);
$this->assertEquals($expected, $actual);
}
示例3: deIndex
/**
* De-index operation.
*
* @param Operation $operation
* The operation to index.
* @param string $key
* (optional) The key to index under.
*
* @return Operation
* The operation de-indexed.
*/
public function deIndex(Operation $operation, $key = null)
{
unset($this->operations[$operation->idx($this->connection)]);
if (isset($key)) {
unset($this->index[$key][$operation->idx($this->connection)]);
}
return $operation;
}
示例4: update
public function update(Operation $operation)
{
$query = $this->_db->prepare('UPDATE t_operation SET date=:date, montant=:montant WHERE id=:id') or die(print_r($this->_db->errorInfo()));
$query->bindValue(':date', $operation->date());
$query->bindValue(':montant', $operation->montant());
$query->bindValue(':id', $operation->id());
$query->execute();
$query->closeCursor();
}
示例5: getBalanceOperation
/**
* Возвращает операцию начального остатка
* @return Operation
*/
private function getBalanceOperation()
{
if (is_null($this->balanceOperation)) {
$params = array($this->getId(), Operation::TYPE_BALANCE);
$this->balanceOperation = Doctrine_Query::create()->from('Operation o')->andWhere("account_id = ? AND type = ?", $params)->fetchOne();
if (!$this->balanceOperation) {
$params = array('user_id' => $this->getUserId(), 'amount' => 0, 'date' => '0000-00-00', 'category_id' => NULL, 'type' => Operation::TYPE_BALANCE, 'comment' => 'Начальный остаток', 'accepted' => 1);
$this->balanceOperation = new Operation();
$this->balanceOperation->fromArray($params);
}
$this->balanceOperation->setAccount($this);
}
return $this->balanceOperation;
}
示例6: _makeMessage
/**
* Полное сообщение с описанием операции (для email)
*
* @param Operation $operation
* @return Swift_Message
*/
private function _makeMessage(Operation $operation)
{
$from = array(sfConfig::get('app_notification_email_from') => sfConfig::get('app_notification_email_name'));
$to = $operation->getUser()->getUserMail();
$subject = "Easyfinance.ru - напоминание об операции";
$body = sprintf($this->_template, $operation->getDateTimeObject('date')->format('d.m.y'), $operation->getCategory()->getName(), $operation->getAccount()->getName(), abs($operation->getAmount()), $operation->getAccount()->getCurrency()->getCode(), $operation->getComment());
return $this->_mailer->compose($from, $to, $subject, $body);
}
示例7: 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]);
}
示例8: start
public function start(Operation $op){
$rqs = $op->getRequestService();
$cs = $op->getContextService();
$ts = $op->getTransformService();
$rps = $op->getResponseService();
$model = $rqs->processRequest();
$context = $cs->getContext($model);
$result = $ts->transform($context, $model);
$context = $result[0];
$model = $result[1];
$cs->setContext($context);
echo $rps->processResponse($model);
}
示例9: __construct
public function __construct($operand = null, $operator = null, $OperationType = null)
{
parent::__construct();
$this->operand = $operand;
$this->operator = $operator;
$this->OperationType = $OperationType;
}
示例10: __construct
public function __construct($operand = null, $exemptionRequests = null, $operator = null, $OperationType = null)
{
parent::__construct();
$this->operand = $operand;
$this->exemptionRequests = $exemptionRequests;
$this->operator = $operator;
$this->OperationType = $OperationType;
}
示例11: 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;
}
示例12: lex
/**
* Lex an expression into Script tokens.
*
* @param string $string expression to lex
* @param Context $context the context in which the expression is lexed
* @return array tokens
*/
public function lex($string, $context)
{
// if it's already lexed, just return it as-is
if (is_object($string)) {
return [$string];
}
if (is_array($string)) {
return $string;
}
$tokens = [];
// whilst the string is not empty, split it into it's tokens.
while ($string !== FALSE) {
if (($match = $this->isWhitespace($string)) !== FALSE) {
$tokens[] = NULL;
} elseif (($match = ScriptFunction::isa($string)) !== FALSE) {
preg_match(ScriptFunction::MATCH_FUNC, $match, $matches);
$args = [];
foreach (ScriptFunction::extractArgs($matches[ScriptFunction::ARGS], FALSE, $context) as $key => $expression) {
$args[$key] = $this->parser->evaluate($expression, $context);
}
$tokens[] = new ScriptFunction($matches[ScriptFunction::NAME], $args);
} elseif (($match = Literals\Boolean::isa($string)) !== FALSE) {
$tokens[] = new Literals\Boolean($match);
} elseif (($match = Literals\Colour::isa($string)) !== FALSE) {
$tokens[] = new Literals\Colour($match);
} elseif (($match = Literals\Number::isa($string)) !== FALSE) {
$tokens[] = new Literals\Number($match);
} elseif (($match = Literals\SassString::isa($string)) !== FALSE) {
$stringed = new Literals\SassString($match);
$tokens[] = !strlen($stringed->quote) && Literals\SassList::isa($string) !== FALSE && !preg_match("/^\\-\\w+\\-\\w+\$/", $stringed->value) ? new Literals\SassList($string) : $stringed;
} elseif ($string == '()') {
$match = $string;
$tokens[] = new Literals\SassList($match);
} elseif (($match = Operation::isa($string)) !== FALSE) {
$tokens[] = new Operation($match);
} elseif (($match = Variable::isa($string)) !== FALSE) {
$tokens[] = new Variable($match);
} else {
$_string = $string;
$match = '';
while (strlen($_string) && !$this->isWhitespace($_string)) {
foreach (Operation::$inStrOperators as $operator) {
if (substr($_string, 0, strlen($operator)) == $operator) {
break 2;
}
}
$match .= $_string[0];
$_string = substr($_string, 1);
}
$tokens[] = new Literals\SassString($match);
}
$string = substr($string, strlen($match));
}
return $tokens;
}
示例13: 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);
}
示例14: 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;
}
示例15: 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));
}