You are here

public function AbstractUnitsMathematicalOperator::unitsMathematicalExpressionSave in Units of Measurement 7.2

Save the mathematical expression into database.

Parameters

int $mathematical_expression_id: If the ID of the mathematical expression is known, under which it should be saved, provide it here. Otherwise it will be generated automatically

int $order: Order of this member when the mathematical expression is written down in postfix notation. Primarily this argument is used for internal purposes

Return value

int Mathematical expression ID under which this expression has been saved in the database

Overrides UnitsMathematicalExpression::unitsMathematicalExpressionSave

File

./units.module, line 1495
Provide API for managing and converting units of measurement.

Class

AbstractUnitsMathematicalOperator
Abstract implementation of "mathematical operator" interface.

Code

public function unitsMathematicalExpressionSave($mathematical_expression_id, &$order) {
  $mathematical_expression_id = $this
    ->operand1()
    ->unitsMathematicalExpressionSave($mathematical_expression_id, $order);
  $this
    ->operand2()
    ->unitsMathematicalExpressionSave($mathematical_expression_id, $order);
  db_insert('units_mathematical_expression_postfix')
    ->fields(array(
    'mathematical_expression_id' => $mathematical_expression_id,
    'type' => UNITS_TOKEN_TYPE_OPERATOR,
    'value_string' => $this->operator['name'],
    'postfix_order' => ++$order,
  ))
    ->execute();
  return $mathematical_expression_id;
}